Create wave name from a variable

Very easy problem for you! I tried to find the answer everywhere I could but it still wrong...

I want to call a wave name somewhere in my program like this:

Function test (x)

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
Do it like this:
Function test (x)
Variable x
Wave mywave = $("wavename"+num2str(x))
... // do something with mywave
End
Hi,

checkout
DisplayHelpTopic "Converting a String into a Reference Using $"


The syntax is basically
Function myFunction(str)
string str

wave wv = $str // reads the name of the wave from the *contents* of str
wave wvv = $"myWave"
wave wvv = $("myWave" + "mySuffix")
End

In addition to the documentation referenced by thomas_braun, you should check these out:

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
Thanks a lot for all your answers!

I thought so it was something with references but can't deal with it!

Thanks!