plz help how can repetition rows matrix

1 visualización (últimos 30 días)
eman baky
eman baky el 24 de Jul. de 2021
Editada: eman baky el 24 de Jul. de 2021
how can repetition rows matrix deponds number if i have a=[ 1 0 0 ;0 0 1; 0 1 0] and n=4
i wanna have rep_a=[ 1 0 0; 0 0 1; 0 1 0 ;1 0 0]
if n=5 rep_a=[ 1 0 0; 0 0 1; 0 1 0 ;1 0 0;0 0 1]
  2 comentarios
dpb
dpb el 24 de Jul. de 2021
HINT:
nR=size(a,1);
N=4;
M=fix(N/nR);
C=rem(N,M*nR);
eman baky
eman baky el 24 de Jul. de 2021
Thanks

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 24 de Jul. de 2021
a = [1 0 0; 0 0 1; 0 1 0];
rows = size(a, 1);
n = 5;
index = rem(0:n-1, rows) + 1
index = 1×5
1 2 3 1 2
b = a(index, :)
b = 5×3
1 0 0 0 0 1 0 1 0 1 0 0 0 0 1

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by