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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -