Vector operations

1 Ansicht (letzte 30 Tage)
Steven
Steven am 7 Nov. 2011
I'm looking for something that can repeat a vector without. For exemple, here a is repeated 4 times :
a = [1,2,5];
b = cellfun(a, 4);
b = [1 1 1 1 2 2 2 2 5 5 5 5];
thx

Akzeptierte Antwort

Wayne King
Wayne King am 7 Nov. 2011
One way:
a = [1,2,5];
b = reshape(repmat(a,4,1),12,1);
  1 Kommentar
Andrei Bobrov
Andrei Bobrov am 7 Nov. 2011
b = reshape(ones(4,1)*a,1,[]);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps 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