how to access (or copy) the W_coef and W_sigma from CurveFit in a user defined procedure
Andika Asyuda
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Function medianGaussian(JVmatrice)
wave JVmatrice // 2D wave
Variable sum=0
Variable i=0 // We use i as the loop variable.
Make/O/N=(dimSize(JVmatrice,1)), JV
Make/O/N = (dimSize(JVmatrice,0)), tempwave
Make/N=800/O tempHist;DelayUpdate
do
tempwave = JVmatrice[p][i]
JV[i]=median(tempwave)
Histogram/C/B={-7,0.1,800} tempwave,tempHist;DelayUpdate
CurveFit gauss tempHist /D
print(JV[i])
//calculate inter quartile range
//print(W_coef[1])
//print(W_coef[2])
//print(W_coef[3])
//print(W_coef[4])
i += 1
while(i < dimSize(JVmatrice,1))
return JV[i-1]
End
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Function medianGaussian(JVmatrice)
wave JVmatrice // 2D wave
Variable sum=0
Variable i=0 // We use i as the loop variable.
Make/O/N=(dimSize(JVmatrice,1)), JV
Make/O/N = (dimSize(JVmatrice,0)), tempwave
Make/N=800/O tempHist;DelayUpdate
do
tempwave = JVmatrice[p][i]
JV[i]=median(tempwave)
Histogram/C/B={-7,0.1,800} tempwave,tempHist;DelayUpdate
CurveFit gauss tempHist /D
print(JV[i])
//calculate inter quartile range
//print(W_coef[1])
//print(W_coef[2])
//print(W_coef[3])
//print(W_coef[4])
i += 1
while(i < dimSize(JVmatrice,1))
return JV[i-1]
End
You just need to declare the waves and then you can use them.
WAVE/Z W_coef,W_sigma
September 2, 2020 at 04:55 am - Permalink
To make your code more readable in the forum, please have a look at the following:
https://www.wavemetrics.com/forum/general/formatting-code-forum-posts
In short: You can past your full code into one code-snippet window and select 'Igor' as format.
September 2, 2020 at 07:28 am - Permalink
In reply to To make your code more… by chozo
Which I've done for a few of his posts, to make them more readable. Look for the 'Insert Code Snippet" control on the right side of the editor's ribbon bar.
September 2, 2020 at 10:14 am - Permalink
Thanks for the suggestion sjr51. It totally works.
Thank you also for the suggestion about posting the code chozo and JimProuty.
The latest version of the code is the following:
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
//in progress by Andika Asyuda
Function medianGaussian(JVmatrice)
wave JVmatrice // 2D wave
WAVE/Z W_coef,W_sigma, W_StatsQuantiles
Variable sum=0
Variable i=0 // We use i as the loop variable.
Make/O/N=(dimSize(JVmatrice,1)), JVmedian //define 4 empty waves to save median, interquartile range,
Make/O/N=(dimSize(JVmatrice,1)), JVIQR //Gaussian mean, and standard deviation
Make/O/N=(dimSize(JVmatrice,1)), JVGmean
Make/O/N=(dimSize(JVmatrice,1)), JVGsigma
Make/O/N = (dimSize(JVmatrice,0)), tempwave
Make/N=800/O tempHist;DelayUpdate
do
tempwave = JVmatrice[p][i]
statsQuantiles tempwave
JVmedian[i]=W_StatsQuantiles[2] //take median value from W_StatsQuantiles wave
JVIQR[i]=W_StatsQuantiles[5] //take interquartile range value from W_StatsQuantiles wave
Histogram/C/B={-7,0.1,800} tempwave,tempHist;DelayUpdate
CurveFit gauss tempHist /D
JVGmean[i]=W_coef[2] //take median value from W_StatsQuantiles wave
JVGsigma[i]=W_coef[3] //take interquartile range value from W_StatsQuantiles wave
i += 1
while(i < dimSize(JVmatrice,1))
return JVmedian[i-1]
End
September 4, 2020 at 07:31 am - Permalink