Using lsqcurvefit or nlinfit correctly with some data (possibly power law)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone,
I had a general issue with using the lsqcurvefit and nlinfit tools. I was trying to curve fit some data with power law (or some other nonlinear function possibly but I'm just experimenting) and I'm not sure why my code is having issues:
I'm getting the error "Solver stopped prematurely. lsqcurvefit stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 200 (the default value)..."
I tried setting tolerances as well but I had no luck.
xdata=xlsread('yadi.xlsx','A34:A45');
ydata=xlsread('yadi.xlsx','B34:B45');
fun=@(x,xdata)x(1)+x(2)*xdata.^x(3);
x0=[1,500000,-0.15];
x=lsqcurvefit(fun,x0,xdata,ydata)
0 Commenti
Risposte (2)
the cyclist
il 9 Set 2015
One thing to be aware of is that when people talk about a "linear fit", that is referring to the coefficients, not the independent variables. So, for example, a fit of the type
y = a + b*x + c * x^2
is a linear fit, because a, b, and c appear linearly. The fact that powers of x appear does not make that a non-linear fit (even though is non-linear in x).
So, you may be able to use a linear fitting tool after all.
0 Commenti
Star Strider
il 9 Set 2015
There are two possibilities: increase the maximum number of function evaluations, or change your initial parameter estimates. I don’t have your data, so I can’t offer specific recommendations. However I would start by experimenting with different initial parameter estimates.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!