Area Under Curve for 2D matrix of Peak Functions
n.black
I have a 2D matrix where each column is a Lorentzian curve (that I have made by extracting fit parameters from a curve fit procedure).
I want to calculate the area under the curve form y=0 for each column in the matrix. And put the result in a 1D wave.
NOTE I wanted my y intercept varied from +/-10 and I wanted to make it simple as the function only integrates from 0 and I wanted it all +ve hence the FalseDataMat which takes my original data and shifts it such that the y axis is 0.
Here's a snippit ofwhat I have so far.
Variable i
Variable j
for (j = 0; j < nCols; j += 1)
for (i = 0; i < nRows; i += 1)
FalseData[i][j]=Mat2D[i][j]-y0[j]
endfor
PeakArea[j]=areaXY(wnum,FalseAreaDataMat)
endfor
Variable j
for (j = 0; j < nCols; j += 1)
for (i = 0; i < nRows; i += 1)
FalseData[i][j]=Mat2D[i][j]-y0[j]
endfor
PeakArea[j]=areaXY(wnum,FalseAreaDataMat)
endfor
I saw that the Area function only works on 1D waves. But I don't want to create a list of 1D waves...or do I have to extract.
I tried making a list of 1D waves and then killing them later but that didn't work very well.
Hopefully someone can help me!
Thanks,
N
MatrixOP/O/FREE colWave=col(Mat2D,j)
PeakArea[j]=areaXY(xwave,colWave)
endfor
November 13, 2015 at 10:53 am - Permalink
That did the trick and looks to be a very useful piece of code for me! I started reading the help topics around MatrixOp which is very useful.
Best,
N
PS what did you mean by suitable xwave? Correct dimensions?
November 15, 2015 at 09:18 am - Permalink
The area calculation requires that you have an X-wave that is common for all the columns in your matrix. If you do not have such a wave then use the Integrate operation but in that case you need to apply the appropriate scaling (MatrixOP waves have default wave scaling).
A.G.
WaveMetrics, Inc.
November 16, 2015 at 10:49 am - Permalink
Some Lorentz functions have analytical forms for their areas based on their peak parameters ...
http://magicplot.com/wiki/fit_equations
https://www.physicsforums.com/threads/area-under-the-following-curve-lo…
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
November 16, 2015 at 06:40 pm - Permalink