From: Geraint Paul Bevan <address@hidden>
To: Jorge Civera Saiz <address@hidden>
CC: address@hidden
Subject: Re: Vector of structures in Octave
Date: Sat, 16 Aug 2003 09:21:59 +0100
BEGIN PGP SIGNED MESSAGE
Hash: SHA1
Jorge Civera Saiz wrote:
 Hi everybody,

 I would like to use a vector of structures for my scripts in Octave, but
 I haven't found any way to do that using the data structures described
 in the Octave manual.

 Does anyone know how to do that? or any workaround? My goal is to
 implement a mixture of gaussian distributions where every element of
 this vector is a structure containing relevant information (mean,
 covariance matrix, etc)

 Thanks in advance.

 Jorge
Hi,
you don't say what version of Octave you are using, but a vector of
structures works fine with version 2.1.50
octave:1> a(1).one = 1;
octave:2> a(1).two = 2;
octave:3> a(2).one = 3;
octave:4> a
a =
{
~ one =
~ (
~ [1] = 1
~ [2] = 3
~ )
~ two =
~ (
~ [1] = 2
~ [2] = [](0x0)
~ )
}
octave:5> a(1).one , a(1).two , a(2).one
ans = 1
ans = 2
ans = 3
 
Geraint Bevan
http://homepage.ntlworld.com/geraint.bevan/
BEGIN PGP SIGNATURE
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla  http://enigmail.mozdev.org
iEYEARECAAYFAj896aUACgkQcXV3N50QmNO+cgCghlJS4Fb4TXXoXzQ8ctSB/HG2
mwYAn1Ci28MiBKGXS8YwXG3TOCStbY81
=rPIn
END PGP SIGNATURE

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
