Hello, Good night !!
please could you help me … I am trying to execute the procedure in matlab:
I have a vector
A=[1 2;3 4;5 6;7 8;9 10]
two columns and five rows
And I have a vector
quantity_copies=[1;0;2;2;0]
one column and five rows Each element of the vector quantity_copies is the number of times that the correspondent row of vector A will be copied.
I need a vector
B = [1 2;5 6;5 6;7 8;7 8]
I tried this code:
clear allclcA=[1 2;3 4;5 6;7 8;9 10]quantity_copies=[1;0;2;2;0]n=5for loop=1:n B=repmat(A(loop,:),[quantity_copies(loop,1) 1])end
- IT WORKS BUT, FOR EACH ITERATION, I LOOSE THE OLD VALUES.
PLEASE WHATS THE SOLUTION FOR THIS ?
I NEED TO MERGE ALL VALUES IN ONLY ONE VECTOR B
THANK YOU … * THIS IS THE RESULT OF MY CODE:
A = 1 2 3 4 5 6 7 8 9 10quantity_copies = 1 0 2 2 0n = 5B = 1 2B = Empty matrix: 0-by-2B = 5 6 5 6B = 7 8 7 8B = Empty matrix: 0-by-2>>
Best Answer