Populate a vector in Matlab using a smaller vector

Viewed 68

I need to populate a vector with elements of another, smaller vector. So say the vector I need to populate is of length ten and is currently all zeros, i.e.

vector = [0,0,0,0,0,0,0,0,0,0]

Now suppose I have already define a vector

p = [1, 2, 3, 4, 5]

How could I populate "vector" with the array "p" so that the result is [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]? Bear in mind, I want the other positions in "vector" to remain unchanged. I have already tried using repmat(p, length(p)) but that ends up giving me something of the form [1,2,3,4,5,1,2,3,4,5]. Thanks!

1 Answers
Related