
Iteratively creating & naming numerical variables

benjamin.groff
Hello, I am trying to make a for loop in which I reference a different wave and create a new variable (with a corresponding name) in each iteration, each with specific names. [I think] I was able to do the wave part by iteratively making the string:
string waveref = "waveN2_" + num2str(i+1)
and then calling that specific wave (waveN2_1, waveN2_2, etc.) with $waveref, but I can't figure out how to iteratively make new numerical variables, with corresponding names (E_1, E_2, etc.). I'd then like to assign values to those newly-created&named variables within the loop.
Thank you!

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
You can't create a local variable or string with a run-time name. You *can* make global variables, though, in much the same way as a wave:
February 11, 2020 at 01:15 pm - Permalink
As alternative I'd consider using a labelled wave:
Then you don't clutter up your experiments with global variables and you can make it /FREE if only needed locally.
February 12, 2020 at 12:50 am - Permalink
Thank you both!! Both of these were very helpful.
February 13, 2020 at 07:41 am - Permalink