cell-array returned by anonymous function must be stored in variable before it can be indexed
Olaf Till
olaf.till at uni-jena.de
Fri Apr 4 03:38:53 CDT 2008
On Thu, Apr 03, 2008 at 01:15:09PM -0400, John W. Eaton wrote:
Content-Description: message body text
> On 3-Apr-2008, Olaf Till wrote:
>
> | Octave version: 3.0 (on Debian stable, from a package in unstable)
> |
> | If an anonymous function returns a cell-array, it can not be indexed
> | directly:
> |
> | octave3.0:18> a = @ (x) {x}
> | a =
> |
> | @(x) {x}
> |
> | octave3.0:19> a (1){1}
> | error: scalar cannot be indexed with {
> |
> | but only indirectly:
> |
> | octave3.0:19> t = a (1)
> | t =
> |
> | {
> | [1,1] = 1
> | }
> |
> | octave3.0:20> t{1}
> | ans = 1
> | octave3.0:21>
> |
> | Such issues (having to store in a temporary variable before indexing)
> | are typical in Matlab, I saw it as an advantage of Octave that direct
> | indexing is possible. Maybe it is possible to provide that feature
> | (direct indexing) under all circumstances ...
>
> Please try the following change.
>
> Thanks,
>
> jwe
With the patch, it is fixed. Thank you.
Regards, Olaf
More information about the Bug-octave
mailing list