plz help how can repetition rows matrix

1 vue (au cours des 30 derniers jours)
eman baky
eman baky le 24 Juil 2021
Modifié(e) : eman baky le 24 Juil 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 commentaires
dpb
dpb le 24 Juil 2021
HINT:
nR=size(a,1);
N=4;
M=fix(N/nR);
C=rem(N,M*nR);
eman baky
eman baky le 24 Juil 2021
Thanks

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 24 Juil 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

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by