cell-array returned by anonymous function must be stored in variable before it can be indexed

Olaf Till olaf.till at uni-jena.de
Thu Apr 3 10:32:02 CDT 2008


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 ...

Regards, Olaf


More information about the Bug-octave mailing list