How to evaluate multiple limits in a matrix array MATLAB -
this question:
suppose next 2 arrays:
z = [1 2;3 6;2 4]; y = [1 2 3 5 2 3 5 7 1 0 4 6]
now want this:
x = {[1 2];[3 5 2 3];[2 3 5]}
as can see, variable "x" has corresponding values of vector "y", positions contained variable z. thinking in this:
fun = @(c) y(c(1,1):c(1,2)); x = arrayfun(fun,z)
but doesn't work :(, idea?
x = arrayfun(@(n) y(z(n,1):z(n,2)), 1:size(z,1), 'uni', 0);
Comments
Post a Comment