how to create an array from a given array with the following criteria.
1 回表示 (過去 30 日間)
古いコメントを表示
Say given array is [1 2 3]. I want to create an array with the elements [1 2 3 4 5 2 3 4 5 6 3 4 5 6 7],
In others terms I want to create an array [1:1+4 2:2+4 3:3+4]
I do not want to use for loops as that slows my code considerably.
0 件のコメント
採用された回答
その他の回答 (1 件)
Ameer Hamza
2020 年 6 月 12 日
An alternative solution using automatic array expansion
a = 1:3;
b = reshape(a + (0:4)', [], 1);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!