adding element to the beginning of an array
12 ビュー (過去 30 日間)
古いコメントを表示
I have a array which has been initialized with zeros, I would like to add four elements each time at the beginning of it while keeping its size the same,
I want to add the first four elements from a array to the first four elements to a second array(initialized with zeros) and then the next four till we have all the elements from the first one transfer to the second with the order that I have mentioned perviously and with the same manner.
I think it can be done without using loops, I would like to see the best way that Matlab offers to do this.
for example I have:
a = randi(10,1000,1);
% I want to add the first for elements from a to the beginning of b while keeping the size of b the same, and then the next four from a
% to be and so on..
b = zeros(2048,1);
Any help would be really appreciated :)
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!