Adding Zeroes and Ones into a Vector
古いコメントを表示
I have a 1x300 vector and would like to make it into a 1x400 vector by inserting a 0 after every third element, a 0 after every sixth element and a 1 after the ninth element and then after the twelfth element insert a 0 and repeat the pattern.
So for example if I have
0 0 1 0 1 0 1 0 0
this would become
0 0 1 0 0 1 0 0 1 0 0 1
and so on.
採用された回答
その他の回答 (1 件)
Jos (10584)
2019 年 5 月 21 日
1 投票
Inserting elements at specific locations is not trivial. Years ago I wrote a function INSERTROWS that does this
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!