help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constructing variable names from strings


From: D Peter Siddons
Subject: Re: constructing variable names from strings
Date: Thu, 18 Jun 2015 14:27:16 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Hi Carlo, Ben,
Thanks for your suggestions. Joao's suggestion (using eval) was all I needed to get the job done. I just couldn't find anything suitable in the on-line manual, although, given the hint I could find the relevant manual entries via Google, including those for assigning and all the other related stuff. Curious that there isn't a full function index in the manual.
Thanks all,
Pete.


On 06/18/2015 02:00 PM, Carlo De Falco wrote:
On 18 Jun 2015, at 16:54, D Peter Siddons <address@hidden> wrote:

Is it possible to build a variable name from strings?
yes, you can do that by using assignin, see 'help assignin' for more info.
you may also assign values to the fields of a struct defined via a string 
variable:

value = 1;
str = 'field_name';
struct_variable.(str) = value;
I'd like to batch-process a lot of data. The data is held in directories 
identified by the dataset number, with Octave variable names built (by a C 
program) from the dataset number. I then need to loop through these directories 
to perform more processing, loading the data and saving processed data based on 
the dataset ID. I need to have the variables uniquely identified with the 
dataset because I need to have multiple datasets in memory simultaneously.
I'm not sure I get exactly what you mean, maybe a short example would make it 
clearer?

c.



--
D. Peter Siddons
Detector Development Group Leader
Bldg. 535B
Photon Sciences Directorate,
Brookhaven National Laboratory
Upton, NY 11973

email: address@hidden
Phone: (631) 344-2738




reply via email to

[Prev in Thread] Current Thread [Next in Thread]