大牛们帮我看看这个matlab程序,谢谢
function fourlumpclear all
clc
global theta yexp V21 V23 V24 A xx0 M MH x0
k0 = ; % 参数初值
lb = ; % 参数下限
ub = [+inf+inf+inf]; % 参数上限
xx0=;
M=;
NH=;
tspan=;
ExpData= ...
[1 0.002553 0.002189 0.000629 0.001467
2 0.003354 0.000745 0.000684 0.001973
3 0.002758 0.002128 0.000585 0.001336
4 0.003226 0.003156 0.000672 0.001585
5 0.003495 0.002759 0.000707 0.001658
6 0.003105 0.002974 0.000678 0.001677
7 0.003571 0.001938 0.000791 0.001780
8 0.003073 0.002763 0.000675 0.001594
9 0.002857 0.002761 0.000630 0.001569
10 0.003621 0.001888 0.000679 0.001637
11 0.003228 0.002415 0.000629 0.001522
12 0.003121 0.001553 0.000734 0.001877
13 0.002850 0.002348 0.000636 0.001601
14 0.003406 0.001851 0.000648 0.001570
15 0.003142 0.001809 0.000677 0.001687];
yexp=ExpData(:,2:5);
tspan=;
V21=';
V23=';
V24=';
theta=;
A=';
yexp=ExpData(:,2:5);
= ...
lsqnonlin(@ObjFunclump,k0,lb,ub,[],tspan,xx0,x0,theta,V21,V23,V24,yexp)
ci = nlparci(k,resid,jacobian)
function f = ObjFunclump(k,tspan,x0,theta,V21,V23,V24,A,yexp)
for i=1:length(theta)
x0(1)=xx0(1)/((1+2*NH(i))*M(1));
x0(2)=xx0(2)/((1+2*NH(i))*M(2));
x0(3)=xx0(3)/((1+2*NH(i))*M(3));
x0(4)=xx0(4)/((1+2*NH(i))*M(4));
= ode45(@FCClump,tspan,x0,[],k,theta(i),V21(i),V23(i),V24(i),A(i));
y(i,1) = x(end,1);
y(i,2:4) = x(end,2:4);
end
f1 = y(:,1) - yexp(:,1);
f2 = y(:,2) - yexp(:,2);
f3 = y(:,3) - yexp(:,3);
f4 = y(:,4) - yexp(:,4);
f = ;
function dxdt=FCClump(t,x,k,theta,V21,V23,V24,A)
dxdt =...
[ theta*k(1)*V21*x(2)/(x(1)+x(2)+x(3)+x(4)+A)
-1*theta*(k(1)+k(2)+k(3))*x(2)/(x(1)+x(2)+x(3)+x(4)+A)
theta*k(2)*V23*x(2)/(x(1)+x(2)+x(3)+x(4)+A)
theta*k(3)*V24*x(2)/(x(1)+x(2)+x(3)+x(4)+A)
];
运行后:
??? Error using ==> optim\private\lsqncommon
User supplied function failed with the following error:
Undefined function or variable "y".
Error in ==> lsqnonlin at 147
= ...
Error in ==> fourlump360 at 39
= ... 回复 1 # cupcp 的帖子
要声明Y这个变量。 meiyongyuandeze 发表于 2012-3-17 21:26 static/image/common/back.gif
回复 1 # cupcp 的帖子
要声明Y这个变量。
能帮我调试一下么?多谢了 感觉应该是函数的参数没对应好
页:
[1]