help-octave
[Top][All Lists]
Advanced

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

Problem with array of structures in 2.1.69 (worked in 2.1.50)


From: Reiner.Suikat
Subject: Problem with array of structures in 2.1.69 (worked in 2.1.50)
Date: Mon, 2 May 2005 01:35:36 -0500

Hello all,

I am experiencing a problem with the way octave handles arrays of
structures, which appears to have changed between version 2.1.50 and
2.1.69.
The following works in 2.1.50:
b(2).a=3;
b(3).x=[0 1 2];
b(2).x=5;
At this point I get:
b =
{
  a =
  (
    [1] = []
    [2] = 3
    [3] = []
  )
  x =
  (
    [1] = []
    [2] = 5
    [3] =

            0        1        2

  )
}
Which is fine. 
I also get:
>> b(2)
ans =
{
  a = 3
  x = 5
}
And
>> b(3)
ans =
{
  a = []
  x =

          0        1        2

}

This looks good to me.
Now in 2.1.69 I get:
b =
{
  a =

  (,
    [1] = [](0x0)
    [2] = 3                <<< notice that there is no entry for [3]=[]
like in 2.1.50
  ,)

  x =

  (,
    [1] = [](0x0)
    [2] = 5
    [3] =

      0  1  2

  ,)

}
Still good, do the commas mean anything or is this just a print
formatting?
Now comes the problem:
octave:12> b(2)
ans =
{
  a = 3
  x = 5
}
But
octave:13> b(3)
error: invalid vector index = 3

Any explanation?
It appears that while 2.1.50 initialises unused array entries
automatically, 2.1.69 is not doing it any more, showing also in this
output:
2.1.50:
>> b.a
ans =
(
  [1] = []
  [2] = 3
  [3] = []
)
But 2.1.69 (same input!)
octave:3> b.a
ans =

(,
  [1] = [](0x0)
  [2] = 3
,)

Obviously octave has not initialised the third entry for b.a.

What can I do to solve this problem?

Thanks
Reiner Suikat



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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