Hi all,
I am still new with Igor. Currently, I am trying to fit a series of histogram with Gaussian equation.
The code seems to work. However the problem is how to retain/copy the fitting coefficient and other fitting information.
The waves containing this information is updated in each iteration. I also didn't manage to copy them in my function.
For some reasons, W_coef and W_sigma waves are unknown.
My code is as the following:
#pragma TextEncoding = "UTF-8"#pragma rtGlobals=3// Use modern global access method and strict wave access.Function medianGaussian(JVmatrice)wave JVmatrice // 2D waveVariablesum=0Variablei=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;DelayUpdatedo
tempwave = JVmatrice[p][i]
JV[i]=median(tempwave)Histogram/C/B={-7,0.1,800} tempwave,tempHist;DelayUpdateCurveFitgauss 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 += 1while(i<dimSize(JVmatrice,1))return JV[i-1]End
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.
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 TextEncoding = "UTF-8"#pragma rtGlobals=3// Use modern global access method and strict wave access.//in progress by Andika AsyudaFunction medianGaussian(JVmatrice)wave JVmatrice // 2D waveWAVE/Z W_coef,W_sigma, W_StatsQuantiles
Variablesum=0Variablei=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 deviationMake/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;DelayUpdatedo
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;DelayUpdateCurveFitgauss 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 wavei += 1while(i<dimSize(JVmatrice,1))return JVmedian[i-1]End
You just need to declare the waves and then you can use them.
WAVE/Z W_coef,W_sigmaSeptember 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:
September 4, 2020 at 07:31 am - Permalink