In the following boiled down example illustrating the error, the function f_what(..) should return the values of input argument y at indices in the array ts:
function Y = f_what(y, ts)
function get_out = get(t)
get_out = y(t);
end
Y = arrayfun(get, ts);
end
Calling it:
>> f_what(1:10, 1:5)
Error using f_what/get (line 4)
Not enough input arguments.
Error in f_what (line 7)
Y = arrayfun(get, ts);
Also, for some reason, the following, where get(..) should be the same as the one above, works:
function Y = f_what(y, ts)
get = @(t) y(t);
Y = arrayfun(get, ts);
end
Calling it:
>> f_what(1:10, 1:5)
ans =
1 2 3 4 5
"Not enough input arguments" ... arrayfun(..) should call its first argument with, in this case, one argument. And get(..) has one input argument. I don't get why it's not enough.
Edit: even more boiled down:
function Y = f_what
function get_out = get_(t)
get_out = t;
end
Y = arrayfun(get_, 1:5);
end
Still the same error.
Edit 2: It works if I supply @get to the first argument of arrayfun(..), instead of get. But I still don't get why it doesn't work without the @.