Adding two matrix together
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Cside
am 13 Okt. 2019
Kommentiert: Star Strider
am 13 Okt. 2019
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 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Okt. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!