简体   繁体   中英

How to put waves into functions in procedures in Igor64

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?

Do the waves lambda / KK / w / Q / delta exist in the current datafolder?

The passed waves wave1 / wave2 / wave3 need to exist as well in the current data folder.

You can turn on debugging and debug on error so that Igor Pro pops into the debugger when an error happens.

I solved it this way below:

Function elipticity_calculation(rotation, elipticity, energy, calculated_elipticity)

Wave rotation, elipticity, energy
String calculated_elipticity

Duplicate/O elipticity, $calculated_elipticity
Wave calc_elipticity = $calculated_elipticity

Duplicate/FREE energy, lambda
lambda = ...
Duplicate/FREE energy, KK
KK = ...
Duplicate/FREE energy, w
w = ...
Duplicate/FREE energy, Q_1
Q_1 = ...
Duplicate/FREE energy, delta
delta = ...


calc_elipticity = ((elipticity-rotation*cos(delta))/sin(delta))

End

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM