Hello, If I have a matrix that looks like this:
A = [[1, 0, 0, 5, 10, 5, 100, 300];[1, 0, 0, 5, 10, 5, 100, 400];[1, 0, 0, 5, 10, 5, 100, 450];[1, 0, 0, 5, 10, 5, 100, 500];[1, 0, 0, 5, 10, 5, 100, 550];[1, 0, 0, 5, 10, 5, 100, 600];[1, 0, 0, 5, 10, 5, 100, 700];[1, 0, 0, 4, 10, 4, 100, 300];[1, 0, 0, 5, 10, 5, 100, 450];[1, 0, 0, 5, 10, 5, 100, 800];];
and a vector that looks like this:
B = [ 1; 2; 1; 3; 2;1];
How can I split my matrix A according to this rule: The first sub-matrix A has a row number equal to the first value of B The second sub-matrix A has a row number equal to the second value of B etc. I would like to store the split sub-matrices in separate cells. So essentially, the first cell will look like this: 1, 0, 0, 5, 10, 5, 100, 300 the second cell will look like this:
1, 0, 0, 5, 10, 5, 100, 400 1, 0, 0, 5, 10, 5, 100, 450
Best Answer