0

I am new to matlab and got some intro questions.

If i have a vector A = (1,0,1)

I would like to duplicate each cell 5 times to get

B = (1,1,1,1,1,0,0,0,0,0,1,1,1,1,1)

Which ways are there to do it?

  • 1
    There are plenty of ways and this question has been asked many times before. Google this exact question and you'll get many solutions. – Benoit_11 Nov 26 '14 at 18:43

1 Answers1

0

One way to do this is to replicate the vector in an additional dimension and then reshape back to the original dimension.

B = reshape(repmat(A,5,1),1,[])
TallBrianL
  • 1,230
  • 1
  • 9
  • 14