How to perform repmat function to repeat rows of a matrix
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Zee
le 19 Août 2022
Modifié(e) : Marco Caputano
le 25 Sep 2025 à 10:33
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3]
I would like to repeat each row for n times and get output something like this when n is 2:
output=[1,0,0,0,1;1,0,0,0,1;2,0,0,0,2;2,0,0,0,2;3,0,0,0,3;3,0,0,0,3]
0 commentaires
Réponse acceptée
Bruno Luong
le 19 Août 2022
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3]
A(repmat(1:end,2,1),:)
2 commentaires
Marco Caputano
le 25 Sep 2025 à 8:49
Modifié(e) : Marco Caputano
le 25 Sep 2025 à 10:33
indeed that works! it took me some time to get it, however thanks! :-D
Plus de réponses (5)
Bruno Luong
le 19 Août 2022
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3]
reshape(repmat(reshape(A,1,1,[]),2,1,1),[],size(A,2))
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!