octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Structures 6.1.1 Basic Usage and Examples


From: Julien Bect
Subject: Re: Structures 6.1.1 Basic Usage and Examples
Date: Tue, 13 May 2014 15:48:53 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Le 13/05/2014 14:35, Mike Miller a écrit :
On Tue, May 13, 2014 at 09:52:11 +0200, Andreas Weber wrote:
The manual
http://www.gnu.org/software/octave/doc/interpreter/Basic-Usage-and-Examples.html#Basic-Usage-and-Examples
shows

x.a = 1;
x.b = [1, 2; 3, 4];
x.c = "string";
x.b.d = 3;
error: invalid assignment to cs-list outside multiple assignment

which works in Matlab and since it's in the manual I guess this also
worked in octave somewhen prior 3.6.2.

I'm not sure if this is related to
https://savannah.gnu.org/bugs/?func=detailitem&item_id=32381
That looks related to me. According to the bug report this worked in
3.2 and was changed for 3.4.

Perhaps fix the manual to use either

   x.b = [];
   x.b.d = 3;

or

   x.b = struct ("d", 3);

instead?

The example from Octave's documentation :

    x.a = 1;
    x.b = [1, 2; 3, 4];
    x.c = "string";
    x.b.d = 3;

runs without even a warning in both Matlab R2012a and Matlab R2013a.

The example from the older bug report :

    x = 1;
    x.a = 2;

also results in overwriting the scalar value 1.0 with a structure, but this time with a warning :

??? Warning: Struct field assignment overwrites a value with class "double". See MATLAB 7.0.4 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning for details.

I don't know about R2013b or R2014a.

Both examples currently fail in Octave (with a different error, though).

Unless Matlab's behaviour has recently changed, I would say this is a bug in the code, not in the documentation.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]