Clear Filters
Clear Filters

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)
I am trying to generate a vector with specified number of ones in it? Using for loop ,is it possible to generate it?

Answers (1)

Azzi Abdelmalek
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)]

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!