[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cs-lists, structure arrays ....
From: |
Shai Ayal |
Subject: |
Re: cs-lists, structure arrays .... |
Date: |
Tue, 05 Apr 2005 15:49:05 +0300 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
Thanks David and Stefan, your replies really helped me.
So to some it up, currently in octave, for a cs-list you can convert it to
a vector or cell array by doing [list] and {list} respectively, so plotting
all the heights in my fictitious data is as easy as
plot([data.height])
Thanks again,
Shai
p.s. I will try to put this in the wiki
Shai Ayal wrote:
Hi all,
I'm getting a bit lost in the list/cell/structure constructs. My data is
most naturally adapted to be in a array of structures:
data(1).name="Shai"
data(1).height=189
data(1).weight="undisclosed"
data(2).name="....
now, how do I extract the heights of everyone ?
data(:).height gives me a "cs-list" type which is no-where documented
and I can't seem to convert it to a vector (or in fact to anything). The
only way I found is using a for loop on the structure array
hh=zeros(1,length(data));
for i=1:length(data), hh(i)=data(i).height; endfor
but this is not very "comfortable".
Also, if you have any suggestions on better data-structures to hold this
kind of data feel free
Shai
-------------------------------------------------------------
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
-------------------------------------------------------------
--
Shai Ayal, Ph.D.
Head of Research
BioControl Medical BCM
3 Geron St.
Yehud 56100
ISRAEL
Tel: + 972 3 6322 126
Fax: + 972 3 6322 125
email: 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
-------------------------------------------------------------