help-octave
[Top][All Lists]
Advanced

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

RE: arrays (matrices) of structures.


From: Steve Goncalo
Subject: RE: arrays (matrices) of structures.
Date: Wed, 17 Oct 2001 18:56:35 -0400

Octave (2.1.34) accepts the syntax of an array of structures on the left
hand side of
an assignment, but somehow manages to ignore the index operation. The same
syntax does not
work on the right hand side. Octave does not currently support arrays of
structures.
It does support structures of structures (a.b.c) and arrays of atomic types
as elements of
structures. The path variable is supported, but it may be illegal to append
to an empty path.

octave:1> b(1).a=1.0
b.a = 1
octave:2> b(1).c=2.0
b.c = 2
octave:3> b(2).a=3.0
b.a = 3
octave:4> b(3).c=4.0
b.c = 4
octave:5> b
b =
{
  a = 3
  c = 4
}
octave:6> b(1)
error: can't perform indexing operations for struct type
octave:6> b(1).a
error: can't perform indexing operations for struct type
error: can't perform structure reference operations for <unknown type> type
octave:6> ar=eye(3
ar =

  1  0  0
  0  1  0
  0  0  1

octave:7> a.ar=ar
a.ar =

  1  0  0
  0  1  0
  0  0  1

octave:8> a.b=5
a.b = 5
octave:9> a
a =
{
  b = 5
  ar =

    1  0  0
    0  1  0
    0  0  1

}
octave:10>
octave:12> path()

LOADPATH contains the following directories:






octave:13> path('.','..')
ans = .:..
octave:14> path

LOADPATH contains the following directories:

  .
  ..

octave:15> path(path,'/')
ans = .:..:/
octave:16> size(path)
ans =

  1  6

octave:17> path

LOADPATH contains the following directories:

  .
  ..
  /

octave:18>
-----Original Message-----
From: Gabe Foster [mailto:address@hidden
Sent: Wednesday, October 17, 2001 2:20 PM
To: address@hidden
Subject: arrays (matrices) of structures.


Hello,

        I'm porting some code from matlab to octave.  I'm not very familier with
either package, so please pardon my ignorance.  I'll try to keep this short.

        The code I'm porting uses arrays of data structures.  It has lines like:
        b(1).a = 1.0
        b(1).c = 2.0
        b(2).a = 3.0
        b(2).c = 4.0

        etc.

        Octave 2.0.16 gives a parse error when trying to parse these lines.  Is
this
because it does not support arrays (or matrices) of structures?

        Octave 2.1.34 seems to be ok with that syntax, but does not seem to 
have a
path variable:

        octave:1> path(path,"/home/gabe/octlib")
        error: `path' undefined near line 1 column 1
        error: evaluating index expression near line 1, column 1

        Any help would be appreciated.

        Thank you for you time...

        --> Gabe
--
 * J. Gabriel Foster  "We have advanced to new and surprising
 * Silicon Grail       levels of bafflement" - Lois McMaster Bujold
 * address@hidden



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





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