作业帮 > 综合 > 作业

我用我的代码解出来变量一直保持在初始值 求大侠指教!

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/18 09:59:07
我用我的代码解出来变量一直保持在初始值 求大侠指教!
我想用matlab解微分方程组,为什么我无法解出来?( 解出来变量一直保持在初始值) 求大侠指教!下面是我的代码.
clear all
clc
global k1 k2 C0 kdEG kaEG kdCBH kaCBH Pf EGt CBHt
k1 = 40;
k2 = 1*10^14;
C0 = 5.56*10^-6;
kdEG = 1*10^-6;
kaEG = 5*10^6;
kdCBH = 1*10^-7;
kaCBH = 5*10^6;
Pf = 0.01;
EGt = input('Enter EGt:');
CBHt = input('Enter CBHt:');
S10 = Pf;
S20 = S10*Pf;
[t,y]=ode45('functionall',[0,15],[0 0 S10 S20 0]);
plot(t,y(3),t,y(4),t,y(5));
%%%%%%%%%%%%%%%%%
function z = functionall(t,y)
global k1 k2 C0 kdEG kaEG kdCBH kaCBH Pf EGt CBHt
z = zeros(5,1);
dydt(1) =((y(3)-y(2)-y(1))*(EGt-y(1)*C0)-kdEG*y(1))*kaEG;
dydt(2) =((y(3)-y(2)-y(1))*(CBHt-y(2)*C0)-kdCBH*y(2))*kaCBH;
dydt(3) = -Pf*(k1*y(1)+k2*y(2)*y(4)*C0);
dydt(4) = k1*y(1)-k2*y(4)*y(4)*y(2)*C0/y(3);
dydt(5) = k2*y(2)*y(4)*C0;
end
有没有大侠可以帮我看看哪儿错了.
我用我的代码解出来变量一直保持在初始值 求大侠指教!
function dydt= functionall(t,y)
global k1 k2 C0 kdEG kaEG kdCBH kaCBH Pf EGt CBHt
dydt= zeros(5,1);
dydt(1) =((y(3)-y(2)-y(1))*(EGt-y(1)*C0)-kdEG*y(1))*kaEG;
dydt(2) =((y(3)-y(2)-y(1))*(CBHt-y(2)*C0)-kdCBH*y(2))*kaCBH;
dydt(3) = -Pf*(k1*y(1)+k2*y(2)*y(4)*C0);
dydt(4) = k1*y(1)-k2*y(4)*y(4)*y(2)*C0/y(3);
dydt(5) = k2*y(2)*y(4)*C0;
end
把z换成dydt
再问: 这样修改之后反而运行不了了。。 是有其他什么错误吗?
再答: [t,y]=ode45(@functionall,[0,15],[0 0 S10 S20 0]);