How to make a column vector of 2 distinct numbers
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dubstep Dublin
am 19 Mär. 2015
Bearbeitet: Konstantinos Sofos
am 19 Mär. 2015
How can I make a 400x1 column vector in the following format..
first 100 rows = all 1's
101st to 400th row = all 2's
I am a matlab newbie so any help to get me started will be greatly appreciated.
Thanks
0 Kommentare
Akzeptierte Antwort
Konstantinos Sofos
am 19 Mär. 2015
Bearbeitet: Konstantinos Sofos
am 19 Mär. 2015
Many possible solutions
V = [ones(100,1);2*ones(300,1)];
or
V = [repmat(1,100,1);repmat(2,300,1)];
or
V = ones(400,1); V(101:end)=2;
or
V(1:100,1)=1;V(101:400,1)=2;
0 Kommentare
Weitere Antworten (3)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!