How can i create a vector with specific values at different positions?

3 ビュー (過去 30 日間)
Martin
Martin 2014 年 7 月 18 日
コメント済み: Martin 2014 年 7 月 18 日
I'm looking forward for a vector with different (0/1) entries at different positions. An Example:
% v=[0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1];
My idea was to create a zeros vector v (1x25) and fill in the values with the colon command.
% v(1,3:7 && 10:14 && 16:18 && 19:end)=1;
Is there any way to fill in the ones with a single line of code?

採用された回答

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2014 年 7 月 18 日
close enough:
v([3:7 10:14 16:18 20:25]) = 1;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by