Info
This question is closed. Reopen it to edit or answer.
Is it possible to create a vector with a specified number of ones? eg . V=[ 1 1 1 1 0 0 0 0 0 0 0 0]
2 views (last 30 days)
Show older comments
I am trying to generate a vector with specified number of ones in it? Using for loop ,is it possible to generate it?
0 Comments
Answers (1)
Azzi Abdelmalek
on 29 Mar 2016
Edited: Azzi Abdelmalek
on 29 Mar 2016
َََََA=zeros(1,12)
A(1:4)=1
Or
A=[ones(1,4) zeros(1,8)]
1 Comment
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!