Filter löschen
Filter löschen

matrix repetition

2 Ansichten (letzte 30 Tage)
zozo
zozo am 9 Jan. 2012
Hello,
I have a matrix M of dimensions (m by n). I want to repeat this matrix 'k' number of times along the column.
For example:
If
M=[1 3 4 5;4 5 6 7;9 3 4 2]
and k=4(say),then
out=[1 3 4 5 1 3 4 5 1 3 4 5 1 3 4 5;4 5 6 7 4 5 6 7 4 5 6 7 4 5 6 7;9 3 4 2 9 3 4 2 9 3 4 2 9 3 4 2]
please help.
  1 Kommentar
Andrei Bobrov
Andrei Bobrov am 9 Jan. 2012
reshape(M(:,:,ones(k,1)),size(M,1),[])

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Rick Rosson
Rick Rosson am 9 Jan. 2012
out = repmat(M,1,k);
  1 Kommentar
zozo
zozo am 9 Jan. 2012
Thank you sir! :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 9 Jan. 2012
repmat(M, 1, 4)
(Note: your example only uses 3 repetitions for the first row)
  1 Kommentar
zozo
zozo am 9 Jan. 2012
sorry..it shud be 4. dats my mistake.
thanks! :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop Apps Using App Designer 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!

Translated by