take name of old wave and make new one out of it
mwpro
I tried
string a
a=nameofstring (compoundA)
string b
b = a +"_calculated"
Duplicate $a $b
then I tried to use
$b = $a/wave2/wave3*wave4 to assign my $b wave.
but always get an error in "cannot use $ this way in a function".
What is this error? How did it happen? What I should do to achieve my purpose then?
Thank you!
e.g.
Wave w0
String wName, newName
wName = NameOfWave(w0)
newName = wName + "_calculated"
Duplicate/O w0 $newName
Wave w1 = $newName // this is making a reference to the wave
w1 = w0 * 10 // or whatever you want to do.
End
Completely untested, but should work if you call with
RenameIt(compoundA)
.March 24, 2017 at 01:10 pm - Permalink
This can sometimes seem confusing. For example, Igor fully expects the arguments in a Duplicate statement to be waves, so you don't have to declare its arguments, and you can use the $. That is not the case for an assignment, though. Assignments can potentially apply to variables, strings, or waves, so you have to inform the function what type each argument is. The statement above tells Igor, whenever I use "wa", what I really mean is that wave that has the name in string a (at the time of declaration). If the string a changes, and you want wa to change with it, then you have to declare it again.
To do the operation, you then do:
The same thing should go for wave2, wave3, and wave4. That is, they need to be declared as waves for Igor to know how to handle them.
Look up the $ operator in the help.
-mxf
March 24, 2017 at 01:40 pm - Permalink
function ()
wave ...
variable ...
string ...
wave wa, wb, w1
.....
and then try to assign $a to wa directly like
wa = $a
but did not pass. It seems the wave reference needs to be immediately ahead of where you use it or want to assign it, declaring the waves up front didn't help. Or maybe I am mixing the function declaration up with wave reference...
But Thanks!
March 24, 2017 at 02:32 pm - Permalink
Wave wa
wa = $a // asking Igor to assign a string to every point of numeric wave
// this will
Wave wa = $a
// whereas this will work
Variable nWaves
nWaves = 12
// or
String wName
wName = "a"
March 25, 2017 at 12:11 pm - Permalink
March 25, 2017 at 10:39 am - Permalink
People forget that the WAVE w=$something is not only a declaration about the relationship, but is is also an assignment. That is, at runtime something (a pointer) actually gets copied at that point in the program execution, so placement matters.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
March 26, 2017 at 07:55 am - Permalink
April 3, 2017 at 10:13 am - Permalink