From help-octave-request at bevo dot che dot wisc dot edu Thu Feb 5 22:16:21 2004 Subject: indexing structures From: "John W. Eaton" To: Scott Skjei Cc: help-octave at bevo dot che dot wisc dot edu Date: Thu, 5 Feb 2004 22:14:55 -0600 On 5-Feb-2004, Scott Skjei 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 -------------------------------------------------------------