4Misc_Startr4Platformr@9VersionCheck xHH@Rg(HHdh xHH@Rg(HHdh x HH@Rg(HHdh ^Graph*2WDashSettings#  ! sO6Normal@ Menlo<HHHH$$4 4 4 4 4 4 homeM=d"JJW HD:Users:jjw_work:Desktop:JJW HDBDDesktop cujjw_work/:Users:jjw_work:Desktop/DesktopJJW HDUsers/jjw_work/Desktop/VRecentWindows"Graph0:HEMG,fit_HEMGInputsNotes 4Misc_EndrTXOPState_Start rPeakFunctions2-64MGInputs4XOPState_EndrV_Flag?V_chisq?ԶE?V_numNaNsV_numINFsV_npnts@Y@V_nterms@V_nheldV_startRowV_endRowY@V_startColV_endColV_startLayerV_endLayerV_startChunkV_endChunk•make/N=101/D HEMG •NewPanel •ShowTools/A arrow •SetVariable setvar0 title="0",size={100,20},proc=SetVarProc,value= _NUM:0,fSize=14 •SetVariable setvar1 title="1" •SetVariable setvar2 title="2" •SetVariable setvar3 title="3" •SetVariable setvar4 title="4" •SetVariable setvar5 title="5" •SetVariable setvar6 title="n",rename=setvarn •SetVariable setvarn limits={0,0.1,0.01} •HideTools/A •DoWindow/C/T Inputs,"Inputs" •display HEMG •SetScale/P x 0,0.2,"", HEMG •ModifyGraph mode=3,marker=19,rgb=(0,0,0) •SetAxis left 0,0.3 •FuncFit HEMG11 coeff HEMG /D Fit converged properly fit_HEMG= HEMG11(coeff,x) coeff={3.0551,0.87394,3.024,7.9536,2.0003,-0.00012277} V_chisq= 0.0006431;V_npnts= 101;V_numNaNs= 0;V_numINFs= 0; V_startRow= 0;V_endRow= 100; W_sigma={0.247,0.724,0.147,0.333,0.0549,0.00224} Coefficient values ± one standard deviation ww_0 = 3.0551 ± 0.247 ww_1 = 0.87394 ± 0.724 ww_2 = 3.024 ± 0.147 ww_3 = 7.9536 ± 0.333 ww_4 = 2.0003 ± 0.0549 ww_5 = -0.00012277 ± 0.00224 •ModifyGraph lsize(fit_HEMG)=2,rgb(fit_HEMG)=(52428,1,1) •ModifyGraph lsize(fit_HEMG)=3 •SetAxis left 0,0.25 •ShowTools/A arrow •Button buttonDo title="Do Fit",size={60,20},proc=ButtonProc,fSize=14 •HideTools/A Fit converged properly fit_HEMG= HEMG11(coeff,x) coeff={3.0529,0.87943,3.0265,7.9554,2.0011,-0.00015243} V_chisq= 0.000643074;V_npnts= 101;V_numNaNs= 0;V_numINFs= 0; V_startRow= 0;V_endRow= 100; W_sigma={0.246,0.716,0.149,0.329,0.0552,0.00225} Coefficient values ± one standard deviation ww_0 = 3.0529 ± 0.246 ww_1 = 0.87943 ± 0.716 ww_2 = 3.0265 ± 0.149 ww_3 = 7.9554 ± 0.329 ww_4 = 2.0011 ± 0.0552 ww_5 = -0.00015243 ± 0.00225 Fit converged properly fit_HEMG= HEMG11(coeff,x) coeff={2.7088,3.502,3.6182,7.9732,2.1638,-0.0051533} V_chisq= 0.00115631;V_npnts= 101;V_numNaNs= 0;V_numINFs= 0; V_startRow= 0;V_endRow= 100; W_sigma={0.189,0.444,0.471,0.0222,0.154,0.00496} Coefficient values ± one standard deviation ww_0 = 2.7088 ± 0.189 ww_1 = 3.502 ± 0.444 ww_2 = 3.6182 ± 0.471 ww_3 = 7.9732 ± 0.0222 ww_4 = 2.1638 ± 0.154 ww_5 = -0.0051533 ± 0.00496 •NewNotebook/F=1/N=Notes !ޑ+hϘ8;eHEMGe????w%؊e?{?h'8??1$njR?s?KG?C1 .? s}#?2Lܦ?\YP?bV?X"?W>?lA|?S&F?_K?)C?xSz 56?=?hW/?_D?Qf5?;' J?vBO?" ^v?B=(?} ?3D-? TNe?ʫ?5 k?tx?pÿ?ΎuϾ?{A'ƽ?|U?w$ں?Y?JP(Ĺ?(hZ? ѭw??'<ݶ?4Hq^?c0?s,V?bs Ey ?!qiV?̾?סxc^?;b?2?]3?hUE?M*Oq?{??Rޒ?} t?Gc?uq?ʹʺ?#Yb?r`\n?/t ҈?`鼒;?9?T3 ?p;;coeff????X"ȉ@ie @2,X @FY@eO@/u] v V;;fit_HEMG\????7 ?R ?gb?` ?0찀?82e?жI ?8s ~ӧ?[)Uː?ࡻ?$S?yn5?q ?tSO?h(?#zf?RE?Z])?\q ? Bg?mQ0?u?:?rlt?`[?2t.Ƙ|? ]?fɍ? Z?$@?Hhp7?jHev@ɶ?O\?:k6?iV%?t3!?nO?~EV?tܫJ?|5?`-,?l˼?mwi?>te?s" ?=:E??@#Z@?kX?o/Xf?E\)?:ru?Ynr?! ?qiS?$JY?-O&{?⤉&?K{h?RJʩ?{?%?C`?a&?)=X?N?L{2?7_?u&㗊?be??jM?5?'1?DI?E$]?7vSn?O/{{?(6?=:?]?u?xpDn?f ȗs?WFl? x?K?o$?8QeD?OQG?˃^?xu? -? ??|O?(z2?ѿm?YvRwj?-Bv?ԝ?xj?.fd?>ǽ? D+?l8鎼?>?k7UW?K9?$<#$?;x苹?M\? g_?+a˷?o8?@V? ?15!?)?ax? )?QȡOm?R?jyHk?9K?GH"r?^+?n q?_?{ ??:48?B^Y?:~? ?2cbث?v` ?( DD?N.C?m ¨?n9?h`S?C?ny?SbF}L?i^/?2W?m$l?sӢ?t??D?>9"??E!?z'"?0w%?A.? >?35U?5‘q?.|W?h༘?Zf1?3&?,RX?~i?dq۔?l&a$?Kr?HtqŒ??AEP?]*?[sy ?+^?I+>??EF?J"?ΊV?$??H?<*)?v3K?'i;s?PEؠ?fit_HEMG= HEMG11(coeff,x) coeff={2.7088,3.502,3.6182,7.9732,2.1638,-0.0051533} V_chisq= 0.00115631;V_npnts= 101;V_numNaNs= 0;V_numINFs= 0; V_startRow= 0;V_endRow= 100; W_sigma={0.189,0.444,0.471,0.0222,0.154,0.00496} Coefficient values ± one standard deviation ww_0 = 2.7088 ± 0.189 ww_1 = 3.502 ± 0.444 ww_2 = 3.6182 ± 0.471 ww_3 = 7.9732 ± 0.0222 ww_4 = 2.1638 ± 0.154 ww_5 = -0.0051533 ± 0.00496 p*;;W_sigma????wM4?0 e?aR!?n?G=C?ĚyTt?*zd0TMW0RGINotesNotesNotes[/[/HH@Rg(HHdh -3#4-3#4$Normal 6< BHHHH$$dDZ & 2022-05-16  (I created the function that you posted.  7I created an input control panel for the coefficients. The input n is a noise level.  (I created a wave HEMG to hold the data.  )I linked the inputs to run the function.  7I created a test input for a certain set of values and #scaled the graph for those values.  0I added noise to the curve and ran a curve fit.  -I added a Do Fit button to run the curve fit.Zlt BJz(0Helvetica// Platform=Macintosh, IGORVersion=8.050, architecture=Intel, systemTextEncoding="MacRoman", historyTextEncoding="UTF-8", procwinTextEncoding="UTF-8", recreationTextEncoding="UTF-8", build=37523 #pragma TextEncoding = "UTF-8" Silent 101 // use | as bitwise or -- not comment. DefaultFont "Helvetica" MoveWindow/P 461,115,1103,518 Graph0() Inputs() MoveWindow/C 81,496,554,734 String/G root:gWMSetNextTextFilesTextEncoding = "MacRoman" // Text encoding for Notes. Used by Igor Pro 7. OpenNotebook/N=Notes/W=(569,203,976,590)/J=10891 "Notes" KillStrings/Z root:gWMSetNextTextFilesTextEncoding Window Inputs() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(569,54,809,174) as "Inputs" SetDrawLayer UserBack SetVariable setvar0,pos={4.00,7.00},size={100.00,20.00},proc=SetVarProc,title="0" SetVariable setvar0,fSize=14,value= _NUM:3 SetVariable setvar1,pos={121.00,6.00},size={100.00,20.00},proc=SetVarProc,title="1" SetVariable setvar1,fSize=14,value= _NUM:3 SetVariable setvar2,pos={6.00,26.00},size={100.00,20.00},proc=SetVarProc,title="2" SetVariable setvar2,fSize=14,value= _NUM:3 SetVariable setvar3,pos={116.00,27.00},size={100.00,20.00},proc=SetVarProc,title="3" SetVariable setvar3,fSize=14,value= _NUM:8 SetVariable setvar4,pos={3.00,48.00},size={100.00,20.00},proc=SetVarProc,title="4" SetVariable setvar4,fSize=14,value= _NUM:2 SetVariable setvar5,pos={115.00,48.00},size={100.00,20.00},proc=SetVarProc,title="5" SetVariable setvar5,fSize=14,value= _NUM:0 SetVariable setvarn,pos={117.00,73.00},size={100.00,20.00},proc=SetVarProc,title="n" SetVariable setvarn,fSize=14,limits={0,0.1,0.01},value= _NUM:0.03 Button buttonDo,pos={25.00,83.00},size={60.00,20.00},proc=ButtonProc,title="Do Fit" Button buttonDo,fSize=14 EndMacro Window Graph0() : Graph PauseUpdate; Silent 1 // building window... Display /W=(35,53,574,514) HEMG,fit_HEMG ModifyGraph mode(HEMG)=3 ModifyGraph marker(HEMG)=19 ModifyGraph lSize(fit_HEMG)=3 ModifyGraph rgb(HEMG)=(0,0,0),rgb(fit_HEMG)=(52428,1,1) SetAxis left 0,0.25 EndMacro P#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. Function HEMG11(wave ww,variable xx) : FitFunc Variable xw, ww02, temp1, temp2, rtn xw = xx - ww[3] ww02 = ww[0]^2 temp1=(1/(4*ww[1]))*exp((xw/ww[1])+((ww02)/(2*ww[1]^2)))*erfc((1/sqrt(2))*((xw/ww[0])+(ww[0]/ww[1]))) temp2=(1/(4*ww[2]))*exp((-xw/ww[2])+((ww02)/(2*ww[2]^2)))*erfc((1/sqrt(2))*((-xw/ww[0])+(ww[0]/ww[2]))) rtn = ww[4]*(temp1 + temp2) + ww[5] return rtn end Function update_curve() wave HEMG variable n make/O/N=6/D coeff ControlInfo/W=Inputs setvar0 coeff[0] = v_value ControlInfo/W=Inputs setvar1 coeff[1] = v_value ControlInfo/W=Inputs setvar2 coeff[2] = v_value ControlInfo/W=Inputs setvar3 coeff[3] = v_value ControlInfo/W=Inputs setvar4 coeff[4] = v_value ControlInfo/W=Inputs setvar5 coeff[5] = v_value ControlInfo/W=Inputs setvarn n = v_value HEMG = (1+gnoise(n))*HEMG11(coeff, x) return 0 end Function do_fit() wave coeff, HEMG FuncFit HEMG11 coeff HEMG /D return 0 end Function SetVarProc(sva) : SetVariableControl STRUCT WMSetVariableAction &sva switch( sva.eventCode ) case 1: // mouse up case 2: // Enter key case 3: // Live update Variable dval = sva.dval String sval = sva.sval update_curve() break case -1: // control being killed break endswitch return 0 End Function ButtonProc(ba) : ButtonControl STRUCT WMButtonAction &ba switch( ba.eventCode ) case 2: // mouse up // click code here do_fit() break case -1: // control being killed break endswitch return 0 End