Appending Values to a Table
s0585353
My problem is I am calculating a value "integral" for several curvefits and I want to append those values into a column in a table. Please help and Thank you!
Menu "Macros"
"2D Guassian Fit...", My2DGaussianFit()
End
Function My2DGaussianFit()
Variable L, H
Variable ii
Prompt L, "Enter Lowest Tw Value:"
Prompt H, "Enter Highest Tw Value:"
Variable xmin, xmax, ymin, ymax
Prompt xmin, "Enter xmin value: " // Set prompt for x param
Prompt xmax, "Enter xmax value: " // Set prompt for x param
Prompt ymin, "Enter ymin value: " // Set prompt for y param
Prompt ymax, "Enter ymax value: " // Set prompt for y param
DoPrompt "Enter Parameters", L, H, xmin, xmax, ymin, ymax
if (V_Flag)
return -1 // User canceled
endif
for (ii=0; ii<(H); ii+=500)
string waveselection= "avg" + num2str(L+ii)
Wave ws= $waveselection
Wave w1
Wave w3
Display; AppendMatrixContour ws vs {w1,w3}
ModifyContour $waveselection labels=0
ModifyContour $waveselection autoLevels={*,*,35}
CurveFit/NTHR=0 Gauss2D ws[xmin,xmax][ymin,ymax] /X=w1[xmin,xmax] /Y=w3[ymin,ymax] /D
wave W_coef
Variable integral
if (waveExists (W_coef))
integral= W_coef[1]*2*pi* W_coef[3]*W_coef[5]*sqrt(1-W_coef[6]^2)
Print integral
endif
endfor
End
"2D Guassian Fit...", My2DGaussianFit()
End
Function My2DGaussianFit()
Variable L, H
Variable ii
Prompt L, "Enter Lowest Tw Value:"
Prompt H, "Enter Highest Tw Value:"
Variable xmin, xmax, ymin, ymax
Prompt xmin, "Enter xmin value: " // Set prompt for x param
Prompt xmax, "Enter xmax value: " // Set prompt for x param
Prompt ymin, "Enter ymin value: " // Set prompt for y param
Prompt ymax, "Enter ymax value: " // Set prompt for y param
DoPrompt "Enter Parameters", L, H, xmin, xmax, ymin, ymax
if (V_Flag)
return -1 // User canceled
endif
for (ii=0; ii<(H); ii+=500)
string waveselection= "avg" + num2str(L+ii)
Wave ws= $waveselection
Wave w1
Wave w3
Display; AppendMatrixContour ws vs {w1,w3}
ModifyContour $waveselection labels=0
ModifyContour $waveselection autoLevels={*,*,35}
CurveFit/NTHR=0 Gauss2D ws[xmin,xmax][ymin,ymax] /X=w1[xmin,xmax] /Y=w3[ymin,ymax] /D
wave W_coef
Variable integral
if (waveExists (W_coef))
integral= W_coef[1]*2*pi* W_coef[3]*W_coef[5]*sqrt(1-W_coef[6]^2)
Print integral
endif
endfor
End
You need to create a wave using Make and then append data to it. For example:
if (!WaveExists(integrals))
Make/D/N=0 integrals
endif
Wave integrals
Variable numPoints = numpnts(integrals)
integrals[numPoints] = {integral} // Add new point to integrals
After you have created the integrals wave you can display it in a table.
I'm not sure what the problem is. Your code should work if the string variable waveselection contains the name of the contour. You can use a Print statement to verify this.
Try it manually by choosing Graph->Modify Contour Appearance and selecting None from the Labels popup menu. This will show you the command you need.
June 4, 2013 at 01:11 pm - Permalink
I tried using your code for appending values to table but I am getting an error message of "Inconsistent type for a wave reference" for the Make/D/N line.
Also I did figure out how to remove the labels from my curvefit.
Thanks for your help!
June 4, 2013 at 01:43 pm - Permalink
Igor is being excessively picky.
In the first Wave statement add /D after /Z. That will make it happy.
June 4, 2013 at 02:52 pm - Permalink