[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Data structures in Octave

**From**: |
Paul Kienzle |

**Subject**: |
Re: Data structures in Octave |

**Date**: |
Sun, 16 May 2004 10:25:30 -0400 |

`It is easy enough to build up data structures using cell arrays or
``structure arrays, however for performance, you want to avoid loops as
``much as possible.
`
So instead of:
d(1).v = [1,2];
d(1).s = 3;
d(2).v = [3,4];
d(2).s = 7;
d(3).v = [5,6];
d(3).s = 12;
for i=1:length(d), if sum(d(i).v) != d(i).s, i, end; end
you would do:
c.v=[1,2;3,4;5,6];
c.s=[3;7;12];
find(sum(c.v,2) != c.s)

`There are plenty of tutorial resources available. A google search for
``"matlab tutorial" gives 120,000 hits. Octave is close enough to matlab
``that you should be able to use them.
`
Paul Kienzle
address@hidden
On May 16, 2004, at 8:30 AM, Sue Stones wrote:

`The documentation seems to be virtually absent on this area, execept
``to maybe
``imply that these things exist. So I will have to ask here again. (I
``assume
`that there is a limited resorces to produce documentation)

`I am looking for a way to associate a vector with a scalar. eg to
``associate
``p8 = [4; 2]; t8 = 1. I need to loop through a list of these pairs
``and do
`some calculation on the vectors and compare the outcome to the relavant
scalar. I am thinking that some data structure that combined the two
elements in to a set, and then someway of looping through the sets.

`Is there a way of forming these sorts of "unions"? Or is there some
``other way
`of dealing with the problem in Octave?

`To loop through the full set of pairs do i need to include all the
``pairs in
`some over arching data structure?
sue
-------------------------------------------------------------
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
-------------------------------------------------------------