create a vector of 0 and 1s that takes 1 at a fixed interval
1 回表示 (過去 30 日間)
古いコメントを表示
I would like to create a vector of 0s that takes 1 at a given (m) interval. For example, if m=2, the vector will be like
0,0,1,0,0,1,0,0,1,...
what will be a simpler way to create such vector?
0 件のコメント
採用された回答
その他の回答 (2 件)
Sulaymon Eshkabilov
2020 年 8 月 14 日
Hi,
O=zeros(1, 20);
m=input('m = ');
IN=m+1:m+1:numel(O);
O(IN)=1;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!