Hi,
This sounds like it should be really easy, but I can't figure out a way to do it without a loop. I want to avoid loops as I am working with large matrices and speed is important.
I have a 1xm array which I'd like to stack into a nxm matrix. Is there a quick and easy way to do it without a loop?
Thank you!

3 Kommentare

You have a (single) 1xm array? If you need it to be nxm then
repmat(TheArray, n, 1)
France Poirier
France Poirier am 31 Dez. 2020
Thank you very much! Does exactly what I need
France Poirier
France Poirier am 31 Dez. 2020
If you paste it inthe "Answer this question" section I could accept it...

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 31 Dez. 2020

0 Stimmen

You have a (single) 1xm array? If you need it to be nxm then
repeated_matrix = repmat(TheArray, n, 1)
Side note: in current releases, repmat() is a built-in. In older versions, repmat() was a .m file that in this particular case would have come down to
repeated_matrix = TheArray(ones(n,1), :)

Weitere Antworten (0)

Kategorien

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by