Linear Fitting of Multiple X,Y Datasets with Independent Z Variable

I have a 3D array of wavelength, concentration, and absorbance. To calculate the molar absorptivity of this compound I need to perform a linear least squares fit of the concentration vs. absorbance data for each wavelength. There are 6 concentration and 6 absorbance values for each one of the 300 wavelength values.
How can I go about performing this fit? Is it best to iteratively fit the concentration vs. absorbance data for each wavelength?
The final result I am looking for is a slope and standard deviation for each wavelength.
Thanks in advance for the help!

4 Comments

It would seem it's then just 300 separate fits of abs=f(conc), one for each wavelength.
That's easily set up in an array with a loop along columns or arrayfun() using polyfit()
Or, could write it explicitly for the whole array and return array of coefficients and use the backslash operator.
These are possibilities I have considered. However, I will need a bit more guidance as I am still working my way through the basics of Matlab. Any specific code snippets would be greatly appreciated!
Well, is there any advantage in fitting a surface instead of N lines first? Is there any possibility owing to physical process that there is an interactive term that should be estimated? Etc., etc., etc., ...
First rule of coding is one has to have a clear definition... :)
The wavelength does have a direct bearing on the absorbance. However, this is a quantum mechanical effect having to do with excited state energy levels and the transition dipole moment, etc.
What I am trying to do here is fit Beer's Law to the absorbance data. The formula for this does not implicitly account for the basis of the changes of absorbance with wavelength, it just realizes that each wavelength will have a different absorption coefficient:
Absorbance(n) = epsilon(n)*concentration
So, arrayfun with polyfit seems to be the way to go. I have played around with this, but I am having syntax and other issues.
X = concentration / (1x6 array)
Y = absorbance / (311x6 array)
arrayfun(polyfit(X,Y?,1),???)
How do I pass polyfit the 1x6 array of absorbance values for a given wavelength (i.e. Y(n) = absorbance(n,:))? How can I get a readable list of wavelength, slope, and error?

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 16 Oct 2013

Commented:

on 17 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!