Combining two vectors in a pattern
5 ビュー (過去 30 日間)
古いコメントを表示
Is there a way to combine two vector let's say
a=[1,2,3,4,5,6,7,8,9]
b=[10,20,30,40];
the resulting vector would be
result=[1,2,3,10,20,4,5,6,30,40,7,8,9];
Is it possible to do this without loops
Thanks
0 件のコメント
採用された回答
Walter Roberson
2019 年 7 月 24 日
n = length(a)+length(b);
mask = ismember(mod(1:n, 5), [0 4]);
result = zeros(1, n);
result(~mask) = a;
result(mask) = b;
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!