data=[1;2;8;9;11;12;19;22;24;26;30];
col_row=[1 2;1 4;1 8;1 11;2 4;2 8;2 11;3 10];
rows number in col_row are always ascending order. I need to store result_i matrix w.r.t. data and rows value of col_row matrix as follows.
result_1=[data(2);data(4);data(8);data(11)];
result_2=[data(4);data(8);data(11)];
result_3=data(10);
rows number in col_row always starts with 1. I need to extract second column values of each repeated numbers (1-2) and single number in col_row matrix and create result_i matrix.
Above data is example, actual data matrix is bigger and the maximum row value of col_row matrix is variable. How can I write a code to store result_i matrix?
2 Comments
James Tursa (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/355410-creating-matrix-w-r-t-rows-number-of-another-matrix#comment_482327
Stephen Cobeldick (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/355410-creating-matrix-w-r-t-rows-number-of-another-matrix#comment_482481
Sign in to comment.