nlinfit returns same values
8 次查看(过去 30 天)
显示 更早的评论
Hi, I am having an issue with the nlinfit function in Matlab. I am given some experimental data and trying to fit a curve that I solve for in another file and extract some parameters (ng, Kg) but the nlinfit always returns the same initial guesses. If anybody can help me, I would greatly appreciate it. Below are the files/functions that I used:
This is the main file:
global ng Kg
% exp data
ti=[0;.5;1;1.5;2;2.5;3;3.5;4;4.5;5];% min
Sup=[9.02;7.95;7.24;6.37;5.79;5.42;4.70;4.38;3.91;3.60;3.33];
yi=Sup*10^-3;
% fit estimated parameter to exp data
plot(ti,yi)
Beta=[ng Kg];
Beta0 = [2 .0004 ];
[Beta,resid,J,Sigma] = nlinfit(ti,yi,@esti_j,Beta0);
CI = nlparci(Beta,resid,'jacobian',J)
Beta
This is the file that calls the other 2 functions:(mom_j)
function dudt = mom_j(t,u)
global ng Kg
C_eq = 10^-3;
po = 1277;
sf = 1;
xin = 106*10^-6;
Gode = Kg*(u(4)-C_eq).^ng;
dudt = zeros (4,1);
dudt(1) = 0;
dudt(2) = u(1)*Gode;
dudt(3) = 2*Gode*u(2);
dudt(4) = -po*sf*(3*Gode*u(3));
end
the other function(est_j):
function [t Cf] = esti_j(Beta,ti)
global ng Kg
ng=Beta(1);
Kg=Beta(2);
po = 1277;
sf = 1;
C_eq = 10^-3;
Min = 20*10^-6;
xin = 106*10^-6;
V = 50*10^-6;
c_0 = 9.02*10^-3;
%set of equations describing initial conditions
u0_0 = Min/((xin^3)*po*sf*V);
u1_0 = Min/((xin^2)*po*sf*V);
u2_0 = Min/(xin*po*sf*V);
[t,u] = ode15s(@mom_j,ti,[u0_0 u1_0 u2_0 c_0 ]);
0 个评论
回答(1 个)
Robert Cumming
2011-7-7
do you get any warning messages? If your problem is not solvable - then nlinfit can appear to return the same values, do this and you should see that nlinfit is attempting to change the parameters:
format long
disp ( Beta ) % in your esti_j function
2 个评论
Robert Cumming
2011-7-7
nlinfit starts by incrementing the value in small steps (as its showing above) - so that is working, the size of the following increments depends on what the results you get back are.
The warning message is telling you that there is a problem with your data and/or equation - in that it cannot be "fit"
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Correlation Models 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!