[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: |
Julien Bect |
Subject: |
Re: request test in Matlab, cellfun and anonymous functions with > 1 outputs |
Date: |
Wed, 23 Jul 2014 17:17:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
Le 23/07/2014 11:17, Olaf Till a écrit :
> <snip>
>
> 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
>> tp = {1, 1}
tp =
[1] [1]
>> [a, b] = cellfun (@ (x) tp{:}, {1})
a =
1
b =
1
>> a = @ (x) tp{:}
a =
@(x)tp{:}
>> a(5)
ans =
1