Help with nonlinear robost fitting on nlinfit function. fminsearch works fine but not nlinfit.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
Im trying to fit some data i have to a function. I have used fminsearch and it has worked fine. Except I wanna introduce robost fitting as there are some point that make the whole fitting wrong.
I searched and found that the stat tool already has a function nlinfit that does everything for you so i thought i would use it.
However when i try to use the function in the program it says that i get NaN or Infinity which i dont get with fminsearch and with a separate m-file the data doesnt go into the other function and it says that the values are unknown.
[ndata] = given below
X = ndata(:,2:8)
dT = ndata(:,1);
par0=[2 0.2 1.5 -0.5 -0.5 -0.5]';
this doesn't send X into funtest.
par = nlinfit(X,dT,funtest,par0);
this one return NaN
%funnfit = @(par,ndata)(par(1).*ndata(:,1).^(0.5*par(2)).*ndata(:,2).^(0.5*par(3)).*ndata(:,3).^par(4).*ndata(:,4).^par(5).*ndata(:,5).^par(6));
%par = nlinfit(ndata(:,2:8),ndata(:,1),funnfit,par0);
funtest
function sse=funtest(params,A)
Pcu = A(:,1); Ptot = A(:,2); n = A(:,3); T = A(:,4); nn = A(:,5); Tr = A(:,6); L= A(:,7);
k = params(1); x = params(2); y = params(3); z = params(4); a = params(5); b = params(6);
sse=k.*Pcu.^(0.5*x).*Ptot.^(0.5*y).*n.^z.*Tr.^a.*L.^b;
ndata
1.0e+003 *
0.1085 1.3946 1.8685 0.7500 0.1000 2.6000 0.1800 0.2600
0.1007 1.3643 2.0014 1.0000 0.1000 2.6000 0.1800 0.2600
0.0943 1.3446 2.3106 1.5000 0.1000 2.6000 0.1800 0.2600
0.0877 1.3276 2.9261 2.4700 0.1000 2.6000 0.1800 0.2600
0.1080 1.8367 3.6807 3.0000 0.1000 2.6000 0.1800 0.2600
0.0680 0.7929 1.1946 0.7500 0.0750 2.6000 0.1350 0.2600
0.0657 0.7889 1.3187 1.0000 0.0750 2.6000 0.1350 0.2600
0.0624 0.7848 1.6006 1.5000 0.0750 2.6000 0.1350 0.2600
0.0607 0.7925 2.1888 2.4700 0.0750 2.6000 0.1350 0.2600
any help?
0 Commenti
Risposte (2)
bym
il 15 Gen 2012
you need to tell nlinfit that funtest is a function by adding a @ in front of it. e.g.
ndata = 1.0e+003 * ...
[0.1085 1.3946 1.8685 0.7500 0.1000 2.6000 0.1800 0.2600;
0.1007 1.3643 2.0014 1.0000 0.1000 2.6000 0.1800 0.2600;
0.0943 1.3446 2.3106 1.5000 0.1000 2.6000 0.1800 0.2600;
0.0877 1.3276 2.9261 2.4700 0.1000 2.6000 0.1800 0.2600;
0.1080 1.8367 3.6807 3.0000 0.1000 2.6000 0.1800 0.2600;
0.0680 0.7929 1.1946 0.7500 0.0750 2.6000 0.1350 0.2600;
0.0657 0.7889 1.3187 1.0000 0.0750 2.6000 0.1350 0.2600;
0.0624 0.7848 1.6006 1.5000 0.0750 2.6000 0.1350 0.2600;
0.0607 0.7925 2.1888 2.4700 0.0750 2.6000 0.1350 0.2600];
X = ndata(:,2:8);
dT = ndata(:,1);
par0=[2 0.2 1.5 -0.5 -0.5 -0.5]';
par = nlinfit(X,dT,@funtest,par0);
par =
5.5529
1.0964
0.7167
-0.2858
-0.0487
-0.2793
1 Commento
bym
il 15 Gen 2012
generated this warning
Warning: The Jacobian at the solution is ill-conditioned, and some
model parameters may not be estimated well (they are not identifiable).
Use caution in making predictions.
> In nlinfit at 223
Vedere anche
Categorie
Scopri di più su FPGA, ASIC, and SoC Development 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!