How to make a column vector of 2 distinct numbers
显示 更早的评论
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
采纳的回答
更多回答(3 个)
the cyclist
2015-3-19
One way:
x = [repmat(1,[100 1]); repmat(2,[300 1])];
James Tursa
2015-3-19
[ones(100,1);2*ones(300,1)]
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!