Merging and overwiting vectors

Hi
Say I have a vector A = [1;2;3;4;5;6] and B = zeros(20,1). How can I merge those two, in such a way that the size of the resulting vector to have size 20 x 1 and the content of the vector to be [1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0].
When trying Y=[A;B] the results is a 26 element vector.
Thanks for any advice.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 24 de Mzo. de 2017
Y = B;
Y(1:numel(A)) = A;

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 24 de Mzo. de 2017

Comentada:

el 24 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by