Repeat every element in matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dears,
I have a matrix A(3200,3), I want to repeat each element (not repeat the matrix)in this matrix 200 times.
Thank you
2 Kommentare
Akzeptierte Antwort
Roger Stafford
am 28 Jun. 2013
Bearbeitet: Roger Stafford
am 28 Jun. 2013
A = reshape(repmat(A(:)',200,1),[],3);
This repeats the elements in the columns. If you want to repeat the along the rows do this:
A = reshape(repmat(reshape(A',[],1),1,200)',[],size(A,1))';
(Corrected)
4 Kommentare
Roger Stafford
am 29 Jun. 2013
That code I gave you has one more transpose than is necessary. You can do it this way instead:
A = reshape(repmat(reshape(A',1,[]),200,1),[],size(A,1))';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!