Adding two matrix together

1 visualización (últimos 30 días)
Cside
Cside el 13 de Oct. de 2019
Comentada: Star Strider el 13 de Oct. de 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!

Respuesta aceptada

Star Strider
Star Strider el 13 de Oct. de 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 comentarios
Cside
Cside el 13 de Oct. de 2019
i think i got it. Thanks!
Star Strider
Star Strider el 13 de Oct. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by