indexing cell arrays

Thorsten Meyer thorsten.meyier at gmx.de
Sat Jun 6 13:05:30 CDT 2009


Hi,

Jaroslav Hajek wrote:
> On Sat, Jun 6, 2009 at 4:19 PM, Thorsten Meyer<thorsten.meyier at gmx.de> wrote:
>   
>> Hi,
>>
>> While working on the documentation of container types, I found that it is no
>> longer possible to assign to a subarray of cell array c like this:
>>  c{:,2} = 1
>>     
>
> Yes. The correct way is c(:,2) = {1}. I think c(:,2) = 1 still works
> as well. But c{:,2} was surely wrong, because it produces a cs-list
> (and thus represents a sequence of lvalues rather than one).
>   
Also, in the manual, there is an (obsolete) example that shows how to
set elements of a cell array to [] with
    c{:,2}= []     (generates an error in octave 3.1!)
and eliminate elements with
    c(:,2) = []

I found, that the first of the two can now be achieved by
    c(:,2) = {[]}
And the second still works, as does
    c(:,2) = 3

So a scalar gets promoted to a cell array with one entry, while the
null_matrix has the special meaning of eliminating entries in a cell
array (and other array types).

Is this consistent with matlab?

Thorsten

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/octave-maintainers/attachments/20090606/e209fdc0/attachment.html 


More information about the Octave-maintainers mailing list