lsqcurve fit precision problem?

7 Ansichten (letzte 30 Tage)
Fred
Fred am 14 Mär. 2012
I am trying to fit an Arrhenius equation to a set of data points using lsqcurvefit. I keep getting my initial guesses as the resulting parameters from the fits, but it's obviously wrong. I've used lsqcurvefit a bit, so I do not think the problem is in the syntax. I think it's in my data set. The values of my data are in the magnitude of 10^-10; it's very small. My parameters, however, are supposed to be huge. I think it's a precision thing. If I change the units for the data, the resulting parameters are supposed to increase in magnitude.
Here's what I'm doing:
Arrhenius Equation:
function [d]=Arrhenius(constant,t)
a = constant(1);
e = constant(2);
d=a.*exp(-e.*t); %e=Activation Energy/R
%t is inverse temp. (Kelvin): 1/T (1/Kelvin) end
Code:
x = [25+273,35+273,45+273,50+273]; %temp data
x1= 1./x; %inverse temp.
y = [0.3551 0.6390 1.4327 1.4692];
y2 = y.*10^-10 %convert to S.I. units (m^2/s)
guess = [0.002 4000]; lower = [0 100]; upper = [1 10^4];
const = lsqcurvefit(@Arrhenius,guess,x1,y2,lower,upper)
When I run this, all I get for my parameters is my initial guess, which is 0.002 and 40000. I got my initial guesses by using Mathematica, another math program, to fit the data. I really think the problem is because my y2 values are too low. Is there a way around this?

Antworten (1)

Geoff
Geoff am 14 Mär. 2012
Probably, like you say, related to scale.
You can use optimset to adjust the solver:
> opts = optimset('lsqcurvefit');
> opts.TolX
ans =
1.0000e-006
> opts.TolX = 1.0e-12;
> const = lsqcurvefit(@Arrhenius,guess,x1,y2,lower,upper,opts);
Notice you pass opts into the function now.
The TolX field is "termination tolerance on X"
There is also TolFun: "termination tolerance on function value"
Play around =) You should be able to get it going.
-g-

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by