小弟最近刚学习用matlab拟合参数,但编写完运行显示Initial point is a local minimum.得到的k值为k0,求给位大神给指点一下怎么解决这种问题!急求,新人啥也不懂啊!先在此谢过啦!
function zixie
clear all;
clc;
data=[0 8.32 0;
1 7.37 0.211;
2 6.74 0.738;
3 5.92 1.106;
4 5.68 1.296;
5 5.01 1.583;
6 6.09 1.364;
8 5.35 1.84;
10 4.99 2];
x0=[8.32 0];
k0=[10 10 10 10 10 ];
lb=[0 0 0 0 0];
ub=[+inf +inf +inf +inf +inf];
yexp=data(:,2:3);
[k,resnorm,residual,exitflag,output,lambda,jacobin]=lsqnonlin(@objFunc1,k0,lb,ub,[],x0,yexp)
fprintf('\tk1=%.4\n',k(1)),
fprintf('\tk2=%.4\n',k(2)),
fprintf('\tk3=%.4\n',k(3)),
fprintf('\tk4=%.4\n',k(4)),
fprintf('\tk5=%.4\n',k(5))
function f=objFunc1(k,x0,yexp)
tspan=[0 1 2 3 4 5 6 8 10];
[t x]=ode45(@funceqs,tspan,x0,[],k);
y(:,1)=x(:,1);
y(:,2)=x(:,2);
f1=y(:,1)-yexp(:,1);
f2=y(:,2)-yexp(:,2);
f=[f1;f2];
function dxdt=funceqs(t,x,k)
dx1dt=-k(1)*k(2)*x(1)*sqrt(k(3)*x(2))/(k(1)+k(2)*x(1))-k(4)*k(5)*x(2);
dx2dt=k(1)*k(2)*x(1)*sqrt(k(3)*x(2))/(k(1)+k(2)*x(1))+k(5)*x(2);
dxdt=[dx1dt;dx2dt];
Initial point is a local minimum.
Optimization completed because the size of the gradient at the initial point
is less than the default value of the function tolerance.
<stopping criteria details>
k =
10 10 10 10 10
Optimization completed: The final point is the initial point.
The first-order optimality measure, 0.000000e+00, is less than
options.TolFun = 1.000000e-06.
Optimization Metric Options
relative first-order optimality = 0.00e+00 TolFun = 1e-06 (default)
>> |