1

so I have a situation where I need to duplicate elements in a vector. So for example, I have a column vector A = [1,0,1,1,0,1,1]' and I want to duplicate each element 100 times, so I want to end up with [1,1,1,1,1,1....(100th one),0,0,0,0,0,0,0,0,0...(100th zero).........]', you get the idea. My original idea was to make an empty vector say B = []', then create a loop which goes through the elements in A then inserts them into B, if that makes sense?

B = []'
A = [1,0,2,1,1,1,0,1]' 
for i = 1:length(BS)
    B = B + A(i)*100
end

I know this is wrong, I just can't find out how to do this, I know you guys hate questions like this but I honestly have looked every where and can't find an answer. Any help will be appreciated, thanks.

MathsIsHard
  • 277
  • 3
  • 9

0 Answers0