MATLAB: Copy elements to end of row vector – help needed!

MATLAB

Dear Matlab forum,
For my research I have a full EMG row matrix that includes stance and swing phases.
To make this easy to answer, I'll make an example:
Let's call the EMG matrix, matrix 'a', in which stance and swing phases are included. In matrix 'b', in the rows, the indices are mentioned of where the stance phase in matrix a will start and where the stance phase will stop. Here, that would be from row 1:2, row 4:5, row 7:8 etc.
Simply put I desire to write a row matrix 'c', where all the stance phase part will be pasted. In this example c should look like [10 10 20 30 40 40 50 60]'.
How should I define (???) to let the loop fill [c] as a row vector mentioned above? As I'm a novice in this topic, I hope you can help me out. At this point
[c] = [10 20 40 50
10 30 40 60]
and should look like [c] = [10 10 20 30 40 40 50 60];
Thanks,
Jerome
——————————————————————————————–
a = [10 10 20 20 30 30 40 40 50 50 60 60 70 70 80 80 90 90]';
b = [1 4 7 10;
2 5 8 11];
c = []';
% test
c1 = a( b(1,1) : b(2,1),1 )
c2 = a( b(1,2) : b(2,2),1 )
c3 = a( b(1,3) : b(2,3),1 )
for i = 0 : 3
?????????????????????????
c (:,end+1) = a( b(1,1+i) : b(2,1+i), 1)
???????????????????????
end

Best Answer

I don't fully understand your code, but looking to your results, this code should do.
a = [10 10 20 20 30 30 40 40 50 50 60 60 70 70 80 80 90 90]';
b = [1 4 7 10;
2 5 8 11];
c=a(b);
c=reshape(c,1,[])