Adding two matrix together
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have 2 matrix, A (1 x 30) and B (1x60). in B, the numbers from cells 1-30 are zeros and I would like to replace A into the first 30 cells of B, having an end result of 1x60 double.
How may I do that?
Thank you!
0 个评论
采纳的回答
Star Strider
2019-10-13
Try this:
A = rand(1,30); % Create Vector
B = [zeros(1,30) rand(1,30)]; % Create Vector
B(1:30) = A; % Desired Result
You did not mention testing for the zero values, or if any other elements of ‘B’ were zero.
5 个评论
更多回答(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!