Info

此问题已关闭。 请重新打开它进行编辑或回答。

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 次查看(过去 30 天)
I am trying to generate a vector with specified number of ones in it? Using for loop ,is it possible to generate it?

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2016-3-29
编辑:Azzi Abdelmalek 2016-3-29
َََََA=zeros(1,12)
A(1:4)=1
Or
A=[ones(1,4) zeros(1,8)]

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by