creating wave
nstanell
Nathan
Function MatrixChoiceX()
string chosenxmatrix
Prompt chosenxmatrix, "Name of the X Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenxmatrix
wave resultx = $chosenxmatrix
End
Function MatrixChoiceY()
string chosenymatrix
Prompt chosenymatrix, "Name of the Y Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenymatrix
wave resulty = $chosenymatrix
End
Function trapezoidalpeakarea(a,b) : ButtonControl
variable a,b //inputted bounds given by the user
wave xdata = MatrixChoiceX()
wave y data = MatrixChoiceY()
Prompt a, "Lower bound of the peak:"
Prompt b, "Upper bound of the peak:"
DoPrompt "Select the waves and set the upper and lower bounds of peak region", a,b
variable result = 0
variable i
for (i=a; i <= (b-1); i += 1)
result = result + (xdata[i+1]-xdata[(i)])*((ydata[i]+ydata[(i+1)])/2)
endfor
return result
End
string chosenxmatrix
Prompt chosenxmatrix, "Name of the X Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenxmatrix
wave resultx = $chosenxmatrix
End
Function MatrixChoiceY()
string chosenymatrix
Prompt chosenymatrix, "Name of the Y Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenymatrix
wave resulty = $chosenymatrix
End
Function trapezoidalpeakarea(a,b) : ButtonControl
variable a,b //inputted bounds given by the user
wave xdata = MatrixChoiceX()
wave y data = MatrixChoiceY()
Prompt a, "Lower bound of the peak:"
Prompt b, "Upper bound of the peak:"
DoPrompt "Select the waves and set the upper and lower bounds of peak region", a,b
variable result = 0
variable i
for (i=a; i <= (b-1); i += 1)
result = result + (xdata[i+1]-xdata[(i)])*((ydata[i]+ydata[(i+1)])/2)
endfor
return result
End
string chosenxmatrix
Prompt chosenxmatrix, "Name of the X Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenxmatrix
wave resultx = $chosenxmatrix
return resultx
End
Function/WAVE MatrixChoiceY()
string chosenymatrix
Prompt chosenymatrix, "Name of the Y Matrix: ",popup,wavelist("*",";","DIMS:1")
Doprompt "Choose the wave:", chosenymatrix
wave resulty = $chosenymatrix
return resulty
End
Function trapezoidalpeakarea(a,b)
variable a,b //inputted bounds given by the user
wave xdata = MatrixChoiceX()
wave ydata = MatrixChoiceY()
Prompt a, "Lower bound of the peak:"
Prompt b, "Upper bound of the peak:"
DoPrompt "Select the waves and set the upper and lower bounds of peak region", a,b
variable result = 0
variable i
for (i=a; i <= (b-1); i += 1)
result = result + (xdata[i+1]-xdata[(i)])*((ydata[i]+ydata[(i+1)])/2)
endfor
return result
End
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 5, 2014 at 09:25 am - Permalink
variable a,b //inputted bounds given by the user
wave xdata = MatrixChoiceX()
wave ydata = MatrixChoiceY()
Prompt a, "Lower bound of the peak:"
Prompt b, "Upper bound of the peak:"
DoPrompt "Set the upper and lower x bounds of peak region", a,b
variable result = areaxy(xdata, ydata, a,b)
return result
End
You also might want to take a look at AreaXYBetweenCursors:
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 5, 2014 at 09:28 am - Permalink
June 5, 2014 at 11:46 am - Permalink
Not really; you'd have to convert to using a panel and wave widget selector controls.
See File->Examples->Programming->WaveSelectorWidgetExample.pxp
[Edit: okay, actually you *could* write a new string function for the wave prompts that iterated all the waves in all data folders and returns a list of the full paths to those waves. The result would be somewhat unwieldy if you have a complicated datafolder hierarchy.]
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 5, 2014 at 03:06 pm - Permalink