I have a vector v
. I need to form an array a
containing elements specified according to another array b
. Each row in a
(let's denote it by r
) should contain all elements from v
, with starting and ending indices corresponding to the first and last elements given in the matching column in b
. For instance:
A(1, :) = v(b(1, 1):b(2, 1));
A(2, :) = v(b(1, 2):b(2, 2));
A(3, :) = v(b(1, 3):b(2, 3));
and so on. Obviously b(2,:) = b(1,:) + constant
.
Can I do this without a loop in MATLAB?