How to make a column vector of 2 distinct numbers
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (3)
the cyclist
il 19 Mar 2015
One way:
x = ones(400,1);
x(101:400) = 2;
1 Commento
Dubstep Dublin
il 19 Mar 2015
the cyclist
il 19 Mar 2015
One way:
x = [repmat(1,[100 1]); repmat(2,[300 1])];
James Tursa
il 19 Mar 2015
[ones(100,1);2*ones(300,1)]
Categorie
Scopri di più su Resizing and Reshaping Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!