Replacing array with a subset of another array
显示 更早的评论
I have two arrays, A and B.
A=[1;2;3;4];
B=[0;0;0;0;0;0];
I want the replace A into B with the remaining zeros staying. So the output would be:
C=[1;2;3;4;0;0]
How can I do this?
回答(1 个)
Star Strider
2018-4-28
One approach:
A=[1;2;3;4];
B=[0;0;0;0;0;0];
C = B;
C(1:numel(A)) = A;
类别
在 帮助中心 和 File Exchange 中查找有关 Library Development 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!