Suppose I have defined f
and t
as such
f = @(x)(x.^2);
t = [4,5,6];
Then I know that f(t) = [16, 25, 36]
and I would expect to be able to write something like
f(t)(1)
to get 16
right away. As I noted, I can't. Is there a way to chain indexing right after a function call? Perhaps writing the indexing as a MATLAB function? i.e. if l(4)
were just syntactic sugar for, say, index(l, 4)
I would write index(f(t), 1)
. Of course I can define such a function, but I am interested in knowing my options if I were to stick with already defined MATLAB functions and/or behavior.