Say that I have a function foo
defined as
[a b] = foo(c ).
If I consider a function handle
f = @(c)foo(c)
to be used e.g. in a cellfun
call, what I get is an f
behaving equivalently to a foo
defined like
a = foo(c)
i.e., the returned value b
gets lost.
Therefore, when such an f
is put in a cellfun
call, the output cell will have just the a
s and will miss the b
s (which I currently care about). Visually
cellfun(f,input)
[a(input{1})] ?
[a(input{2})] ?
.... b gets killed along the way
Question: how to define a function handle to foo
which catches just the b
s? i.e. giving a behavior analogous to a definition of foo
like
b = foo(c)
i.e.^2, wasting the a
s.
Moreover, is it possible to (efficiently) catch both a
and b
in a unique cellfun
call?
cellfun
call; in my case I put[A,B]
and not[~,B]
, my matlab version doesn't support it. So the second point is successfully answered! As far as I can see the general problem of getting the second returned argument in a lambda definition still holds. Isn't it? – Frager