本人刚刚接触matlab,但是无法解决运行时提出的参数不足问题。。。求解答
function P
clear all; clc
k0=[50000 50000 50000 50000 50000]; %参数初值
l=[0 0 0 0 0 ]; u=[+inf +inf +inf +inf +inf +inf];%l、u:参数下限和上限
x0=[16.68 0 0 0 0 0];
DATA2;
global A2
warning off
yexp=A2(:,2:7); %yexp:实验数据[x1 x2 x3 x4 x5 x6]
xm=A2(:,8);
% 使用函数lsqnonlin()进行参数估计
[k,resnorm,residual,exitflag,output,lambda,jacobian]=...
lsqnonlin(@FUNC,k0,l,u,[],x0,xm,yexp)
ci=nlparci(k,residual,jacobian);
%参数辨识结果
fprintf('\n\n使用函数fmincon()估计得到的参数值为:\n')
fprintf('\tk1=%.4f±%.4f\n',k(1),c(1,2)-k(1));
fprintf('\tk2=%.4f±%.4f\n',k(2),c(2,2)-k(2));
fprintf('\tk3=%.4f±%.4f\n',k(3),c(3,2)-k(3));
fprintf('\tk4=%.4f±%.4f\n',k(4),c(4,2)-k(4));
fprintf('\tk5=%.4f±%.4f\n',k(5),c(5,2)-k(5));
fprintf('The sum of the squares is: %.9e\n\n',resnorm)
fprintf(' The sum of the squares is:%.1e\n\n',sum(residual.^2))
function f=FUNC(k,x0,yexp,xm)
tspan=[0 30 40 50 60 70 80 90 120 180 240];
[t x]=ode45(@K,tspan,x0,[],k);
y(:,1:6)=x(:,1:6);
f1=y(:,1)-yexp(:,1);
f2=y(:,2)-yexp(:,2);
f3=y(:,3)-yexp(:,3);
f4=y(:,4)-yexp(:,4);
f5=y(:,5)-yexp(:,5);
f6=y(:,6)-yexp(:,6);
f=[f1;f2;f3;f4;f5;f6];
%----------------------------------------模型方程
function dxdt=K(t,x,k,xm)
dxdt=...
[(-k(1)*xm.^2*x(1)-k(2)*x(1)*x(2)-k(3)*x(1)*x(3)-k(4)*x(1)*x(4)-k(5)*x(1))
(k(1)*x(1)*xm.^2-k(2)*x(1)*x(2))
(k(2)*x(1)*x(2)-k(3)*x(1)*x(3))
(k(3)*x(1)*x(3)-k(4)*x(1)*x(4))
(k(4)*x(1)*x(4)-k(5)*x(1))
(k(5)*x(1))
];
function DATA2
global A2
A2 = ...
[0 16.68 0 0 0 0 0 15.6;
30 15.61 0.85 0.09 0.01 0 0 6.62;
40 14.96 1.02 0.21 0.03 0 0 7.85;
50 14.5 1.06 0.24 0.04 0 0 8.04;
60 12.85 1.46 0.54 0.12 0 0 7.1;
70 13.22 1.44 0.52 0.13 0 0 7.09;
80 11.63 1.78 0.63 0.14 0 0 6.1;
90 10.89 2.97 1.05 0.28 0.05 0 5.03;
100 9.26 2.95 1.16 0.32 0.08 0.01 4.5;
120 8 3.38 1.11 0.31 0.07 0.01 4.55;
150 7.77 3.13 1.27 0.35 0.08 0.01 4.17;
180 7.38 3.49 1.25 0.35 0.08 0.01 4.07;
240 6.58 3.75 1.26 0.36 0.09 0.01 3.84];
错误使用 PODE>K (line 37)
输入参数的数目不足。
出错 odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
出错 ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
出错 PODE>FUNC (line 26)
[t x]=ode45(@K,tspan,x0,[],k);
出错 lsqnonlin (line 193)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
出错 PODE (line 12)
[k,resnorm,residual,exitflag,output,lambda,jacobian]=...
原因:
Failure in initial user-supplied objective function evaluation. LSQNONLIN cannot continue.