Create wave name from a variable
Mantis
I want to call a wave name somewhere in my program like this:
Function test (x)
Variable x
Wave wavename+x
end
Variable x
Wave wavename+x
end
And if I write "test (12)", I want to call the wave "wavename12"...i'me sure it's very easy, but I tried with "num2str" and everything like this but there's no way to work....
Thanks for your answer!
Marc
Variable x
Wave mywave = $("wavename"+num2str(x))
... // do something with mywave
End
August 24, 2012 at 08:31 am - Permalink
checkout
The syntax is basically
string str
wave wv = $str // reads the name of the wave from the *contents* of str
wave wvv = $"myWave"
wave wvv = $("myWave" + "mySuffix")
End
August 24, 2012 at 08:33 am - Permalink
DisplayHelpTopic "Accessing Waves In Functions"
DisplayHelpTopic "Accessing Global Variables And Waves"
DisplayHelpTopic "Wave References"
In case you are unfamiliar with DisplayHelpTopic, all you need to do is copy the command line, paste it into Igor's command line and press Enter.
The first discusses various direct solutions to your problem; the others are more general.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
August 24, 2012 at 09:15 am - Permalink
I thought so it was something with references but can't deal with it!
Thanks!
August 25, 2012 at 01:02 am - Permalink