Include data in a user-defined fitting function
The intensity is a function of frequency, with some fitting parameters. I also have data for refractive index as a function of frequency, and would like this data to be included in the fitting function (so the fitting function has independent variable frequency, dependent variable intensity, and includes a parameter that depends on frequency).
I have tried including refractive index as another independent variable, but unsurprisingly this doesn't work as it depends on frequency.
Any assistance much appreciated,
July 9, 2014 at 03:29 am - Permalink
I would like to use another wave for the refractive index.
Originally I used the curve fitting GUI to input my functions, ignoring the refractive index entirely. This gave the procedure window below.
What I want to do is to insert the data for the refractive index wave for each value of frequency into the expression
(k*(a*frequency)^2*exp(-(b*frequency)) (this is a simplified version)
to give something like
k*refractive_wave*(a*frequency)^2*exp(-(b*frequency))
I have attached the experiment file as well.
Thanks again
____________________________________________________
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Function simple_example(w,frequency) : FitFunc
Wave w
Variable frequency
//CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
//CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
//CurveFitDialog/ Equation:
//CurveFitDialog/ f(frequency) = k*(a*frequency)^2*exp(-(b*frequency))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ frequency
//CurveFitDialog/ Coefficients 3
//CurveFitDialog/ w[0] = k
//CurveFitDialog/ w[1] = a
//CurveFitDialog/ w[2] = b
return w[0]*(w[1]*frequency)^2*exp(-(w[2]*frequency))
End
____________________________
July 9, 2014 at 06:03 am - Permalink
But what I have written here is certainly wrong, because I don't know how the values in the wave should be indexed. The way I have written it, using parentheses, assumes that the wave has the X scaling set so that the values can be looked up directly using the input frequency. The value returned by will be interpolated between the actual values if the frequency falls between values that exist in your wave.
If this is puzzling to you, please read:
DisplayHelpTopic "Waves"
and especially
DisplayHelpTopic "The Waveform Model of Data"
DisplayHelpTopic "Waveform Arithmetic and Assignment"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 9, 2014 at 09:31 am - Permalink