[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: request test in Matlab, cellfun and anonymous functions with > 1 out
From: |
Olaf Till |
Subject: |
Re: request test in Matlab, cellfun and anonymous functions with > 1 outputs |
Date: |
Wed, 23 Jul 2014 11:17:45 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Jul 23, 2014 at 10:58:18AM +0200, Julien Bect wrote:
> Le 23/07/2014 10:36, Olaf Till a écrit :
> >Could someone test these lines in Matlab?
> >
> >octave:1> [a, b] = cellfun (@ (x) {x, x}{:}, {1})
> >error: cellfun: function returned fewer than nargout values
> >
> >and
> >
> >octave:1> a = @ (x) {x, x}{:}
> >a =
> >
> >@(x) {x, x} {:}
>
> >> [a, b] = cellfun (@ (x) {x, x}{:}, {1})
> [a, b] = cellfun (@ (x) {x, x}{:}, {1})
> |
> Error: Unbalanced or unexpected parenthesis or bracket.
>
> >> a = @ (x) {x, x}{:}
> a = @ (x) {x, x}{:}
> |
> Error: Unbalanced or unexpected parenthesis or bracket.
>
>
> (in Matlab R2012a)
Thanks! But I didn't expect this ...
So it returns a syntax error? I meant to provide a simple anonymous
function which returns two outputs ... Maybe this is again the
impossibility to index each expression in Matlab ... so what does it
with these:
octave:1> tp = {1, 1}
tp =
{
[1,1] = 1
[1,2] = 1
}
octave:2> [a, b] = cellfun (@ (x) tp{:}, {1})
error: cellfun: function returned fewer than nargout values
octave:2> a = @ (x) tp{:}
a =
@(x) tp {:}
octave:3> a(5)
ans = 1
ans = 1
?
Olaf
--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net
signature.asc
Description: Digital signature