|
From: | Quentin Spencer |
Subject: | Re: Loading multiple files |
Date: | Fri, 11 Mar 2005 08:48:07 -0600 |
User-agent: | Mozilla Thunderbird 0.9 (X11/20041127) |
Przemek Klosowski wrote:
I think there are usually easier ways to deal with this, as pointed out in other responses to this thread. However, you are allowed to increment elements of string variables in octave, so you could do a "magic increment" doing something as simple as:Thanks for the help. Can something similar be used to increment variable nameswithout eval? I currently use something like:eval(['x',int2str(i),'=zeros(4,4)']); Perl has a neat 'magical string increment' that tries to do a reasonable thing on strings: s="001";s++ gives s="002", and s="abc";s++ gives s="abd". This comes useful exactly in circumstances like those: creating/readingmany files.On the other hand, you have to realize that x1,x2, etc. is a poor substitute for multidimensional arrays, which are supported in latest versions of Octave. The dynamic name creation is only useful for files precisely because you can't have arrays of files, and so you have to simulate them. Having said that, do people like the idea of 'magical increment'? would it be a useful addition to Octave?
octave:1> string = "abc"; octave:2> string(end)+=1 string = abd ------------------------------------------------------------- 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 -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |