I wrote a procedure for making a wave out of another with some calculations. The procedure look like this:
Function elipticity_calculation(rotation, elipticity, energy, calculated_elipticity)
Wave rotation, elipticity, energy
String calculated_elipticity
Wave lambda
lambda = 1240/energy
Wave KK
KK = lambda*lambda
Wave w
w = 1 - 93.33/KK
Wave Q
Q = 1/(w*w*lambda*sqrt(1+135/w))
Wave delta
delta = (Q*1.6*100000+2)*pi/180
Duplicate/O rotation, $calculated_elipticity
WAVE wOut = $calculated_elipticity
wOut = (elipticity-rotation*cos(delta)/sin(delta))
End
However, when I put the function in the command window (see below), it gives me an syntax error:
expected wave name.
elipticity_calculation(wave1, wave2, wave3, "calculated_elipticity")
Where am I wrong?
Thanks
Edit:
I also tried this:
Function elipticity_calculation(rotation, elipticity, energy, calculated_elipticity)
Wave rotation, elipticity, energy
String calculated_elipticity
Make $"lambda"/WAVE=lambda;
lambda = 1240/energy
Make $"KK"/WAVE=KK;
KK = lambda*lambda
Make $"w"/WAVE=w;
w = 1 - 93.0665/KK
Make $"Q"/WAVE=Q;
Q = 1/(w*w*lambda*sqrt(1+136.24/w))
Make $"delta"/WAVE=delta;
delta = (Q*1.69508759865*100000+2.884488929)*pi/180
Duplicate/O rotation, $calculated_elipticity
WAVE wOut = $calculated_elipticity
wOut = (elipticity-rotation*cos(delta))/sin(delta)
End
However, this code create new waves for every calculated point and also create wave wOut empty.
edit:
I tried this. However. It is not working:
Function elipticity_calculation(rotation, elipticity, energy, calculated_elipticity)
Wave rotation, elipticity, energy
String calculated_elipticity
Make/FREE lambda
lambda = 1240/energy
Make/FREE KK
KK = lambda*lambda
Make/FREE w
w = 1 - 93.0665/KK
Make/FREE kve
kve = 1/(w*w*lambda*sqrt(1+136.24/w))
Make/FREE delta
delta = (kve*1.69508759865*100000+2.884488929)*pi/180
Duplicate/O rotation, $calculated_elipticity
Make wOut = (elipticity-rotation*cos(delta))/sin(delta)
End
Is it possible to rewrite a wave after doing some calculation on it? Like in Excel?