[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
indexing structures
From: |
John W. Eaton |
Subject: |
indexing structures |
Date: |
Thu, 5 Feb 2004 22:14:55 -0600 |
On 5-Feb-2004, Scott Skjei <address@hidden> wrote:
| I would like to create a number of data structures with a looping/indexing
| command. The idea I have is
|
| for i = 1:n
| structure(i).element = a(i,:)
| endfor
|
| so each row i of the matrix a becomes an element of structure(i).
|
| Any help would be greatly appreciated.
I don't know of a way to say this in Octave without using a loop, but
maybe someone else has an idea.
If you do use a loop, you will probably want to fill the structure in
reverse order, so that you don't resize it and copy the elements N
times:
for i = n:-1:1
structure(i).element = a(i,:);
endfor
jwe
-------------------------------------------------------------
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
-------------------------------------------------------------