数模论坛

 找回密码
 注-册-帐-号
搜索
热搜: 活动 交友 discuz
查看: 3814|回复: 0

请帮我看看这个程序那个地方出问题了,多谢多谢!

[复制链接]
发表于 2006-3-24 01:33:36 | 显示全部楼层 |阅读模式
<>请帮我看看这个程序那个地方出问题了,多谢多谢!</P>
<>这个程序(matlab)是用来进行非线性参数求解的,我使用了另一个程序改编的,可是就是老出错。请哪位高手帮忙看看。</P>
<>function KineticsEst6<BR>% 动力学ODE方程模型的参数估计<BR>% </P>
<P>clear all<BR>clc<BR>tspan = [0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100];<BR>x0 = [7.7339; 0; 0;0];<BR>k0 = [0.02 0.005 1.25 0.123 0.14 0.13 0.21 0.234 0.536];   <BR>lb = [0 0 0 0 0 0 0 0 0];<BR>ub = [10 10 10 10 10 10 10 10 10];</P>
<P>KineticsData2;<BR>yexp = Kinetics(:,2:5)</P>
<P>% 使用函数lsqnonlin()进行参数估计<BR>[k,resnorm,residual,exitflag,output,lambda,jacobian]= ...<BR>    lsqnonlin(@ObjFunc,k0,lb,ub,[],tspan,x0,yexp);       <BR>ci = nlparci(k,residual,jacobian);<BR>fprintf('\n\n使用函数lsqnonlin()估计得到的参数值为:\n')<BR>fprintf('\tk1 = %.4f ± %.4f\n',k(1),ci(1,2)-k(1))<BR>fprintf('\tk2 = %.4f ± %.4f\n',k(2),ci(2,2)-k(2))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(3),ci(3,2)-k(3))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(4),ci(4,2)-k(4))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(5),ci(5,2)-k(5))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(6),ci(6,2)-k(6))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(7),ci(7,2)-k(7))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(8),ci(8,2)-k(8))<BR>fprintf('\tk3 = %.4f ± %.4f\n',k(9),ci(9,2)-k(9))<BR>fprintf('  The sum of the squares is: %.1e\n\n',resnorm)</P>
<P>% ------------------------------------------------------------------<BR>function f=ObjFunc(k,tspan,x0,yexp)           % 目标函数<BR>[t Xsim]=ode45(@KineticsEqs1,tspan,x0,[],k);   <BR>ysim(:,1)=Xsim(2:end,1);<BR>ysim(:,2)=Xsim(2:end,2);<BR>ysim(:,3)=Xsim(2:end,3);<BR>ysim(:,4)=Xsim(2:end,4);<BR>f=[ysim(:,1)-yexp(:,1);ysim(:,2)-yexp(:,2);ysim(:,3)-yexp(:,3);ysim(:,4)-yexp(:,4)];</P>
<P>% ------------------------------------------------------------------<BR>function dCdt = KineticsEqs1(t,c,k)              % ODE模型方程</P>
<P>r1 = k(1)*c(1)/(k(4)*c(1)+k(5)*c(2)+k(6)*c(3)+k(7));<BR>r2 = k(2)*c(2)/(k(4)*c(1)+k(5)*c(2)+k(6)*c(3)+k(7));<BR>r3 = k(3)*c(2)/((k(4)*c(1)+k(5)*c(2)+k(6)*c(3)+k(8))^0.574);<BR>r4=k(3)*c(3)/(k(4)*c(1)+k(5)*c(2)+k(6)*c(3)+k(9));</P>
<P>dCAdt=-r1-r2;<BR>dCBdt=r1+r4-r3;<BR>dCCdt=r2-r4;<BR>dCDdt=r3;<BR>%dCAdt = -r1;<BR>%dCBdt = 0.5*r1-r2 + r3;<BR>%dCCdt = 0.5*r1-r3;</P>
<P>dCdt = [dCAdt; dCBdt; dCCdt;dCDdt];<BR></P>
您需要登录后才可以回帖 登录 | 注-册-帐-号

本版积分规则

小黑屋|手机版|Archiver|数学建模网 ( 湘ICP备11011602号 )

GMT+8, 2024-11-27 01:38 , Processed in 0.125411 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表