ODE数学答案的Matlab系统也很奇怪

时间:2014-10-18 20:17:43

标签: matlab plot numerical graphing ode

我有两个问题。我需要ODE的最终值,而且我不知道为什么我的图形看起来如此平方。我尝试过更改xaxis缩放。任何帮助都会很棒。我在网上找到的大多数信息似乎都在处理单个ODE,而且我不能完全确定如何获得系统的数值。我不想要每一个价值,只想要最终价值。 谢谢!

function main
%params
k1=6.21e-4;k2=2.15;k3=7.29e-3;k4=1.89;k5=4.95e-2;k6=8.4;
k7=3.5e-2;k8=4.91e-3;k9=4.26e-6;k10=4.65e-5;
k11=29.380;k12=5;k13=6.61e-4;k14=2;k15=2.31e-1;k16=5.54e-3;
k17=5.09e-4;k18=3.21e-2;k19=1.52e-2;
k20=7.20e1;k21=5.53e3;k22=4.25e3;k23=5.57e4;k24=3.8e-3;k25=3.04e-3;
k26=1.92;k27=1.84e-1;k28=3.48;k29=4.66e3;k30=2.41;L=0;

%error
options = odeset('RelTol',1e-6);
%init conditions
Xo=[0;1000;50000;100;1000;0;0;0;0;0;0;0;0;0;0];
%timespan
tspan=[-10^6,10^6];
%solve ode
[t,X]=ode15s(@TestFunctionMembrane,tspan,Xo,options,k1, k2, k3, k4, k5, k6, k7, k8, k9, k10,k11, k12, k13,k14,k15,k16,k17,k18,k19,k20,k21,k22,k23,k24,k25,k26,k27,k28,k29,k30,L);

%figure;hold on; 
subplot(4,4,1);plot(t,X(:,1),'m','LineWidth',2);title('x1'); subplot(4,4,2);plot(t,X(:,2),'m','LineWidth',2);title('x2');  
subplot(4,4,3);plot(t,X(:,3),'m','LineWidth',2);title('x3');  subplot(4,4,4);plot(t,X(:,4),'m','LineWidth',2);title('x4');  
subplot(4,4,5);plot(t,X(:,5),'m','LineWidth',2);title('x5');  subplot(4,4,6);plot(t,X(:,6),'m','LineWidth',2);title('x6');  
subplot(4,4,7);plot(t,X(:,7),'m','LineWidth',2);title('x7');  subplot(4,4,8);plot(t,X(:,8),'m','LineWidth',2);title('x8');  
subplot(4,4,9);plot(t,X(:,9),'m','LineWidth',2);title('x9');  subplot(4,4,10);plot(t,X(:,10),'m','LineWidth',2);title('x10');  
subplot(4,4,11);plot(t,X(:,11),'m','LineWidth',2);title('x11');  subplot(4,4,12);plot(t,X(:,12),'m','LineWidth',2);title('x12');  
subplot(4,4,13);plot(t,X(:,13),'m','LineWidth',2);title('x13');  subplot(4,4,14);plot(t,X(:,14),'m','LineWidth',2);title('x14');  
subplot(4,4,15);plot(t,X(:,15),'m','LineWidth',2);title('x15');  
ylabel('x'); xlabel('t')

function [dx_dt]=TestFunctionMembrane(t,x,k1, k2, k3, k4, k5, k6, k7, k8, k9, k10,k11, k12, k13,k14,k15,k16,k17,k18,k19,k20,k21,k22,k23,k24,k25,k26,k27,k28,k29,k30,L)
%odes
dx_dt(1) = -k17 .* x(1) .* x(7) - k18 .* x(1) .* x(9) - k12 .* x(1) + k24 .* x(5) + k25 .* x(3) + k27 .* x(12);
dx_dt(2) = k4 .* x(3) + k8 .* x(4) .* x(10) - k6 .* x(2) - k16 .* x(2);
dx_dt(3) = k6 .* x(2) - k4 .* x(3) - k11 .* x(3) .* (x(13) .^(k14))./(k26^(k14) + x(13).^(k14)) - k25 .* x(3) + k17 .* x(1) .* x(7) + k13 .* x(5) .*x(10);
dx_dt(4) = k4.* x(5) - k6 .* x(4) - k8.*x(4).*x(10) + k16.*x(2) ;
dx_dt(5) = k6.*x(4) + k11.*x(3).*(x(13).^k14)./(k26^k14 + x(13).^k14) -k4 .* x(5) - k3 .* x(5) .* (x(14) + x(15))+ k30 .* x(11) + k18 .* x(1) .* x(9) - k2 .* x(5) - k24 .* x(5) - k13 .* x(5) .* x(10);
dx_dt(6) = k5 .* x(7) + k7 .* x(8) .* x(10) - k6 .* x(6)  - k28 .* x(6);
dx_dt(7)= k6 .* x(6) - k5 .* x(7) - k10 .* x(7) - k17 .* x(1) .* x(7)  + k9 .* x(9) .* x(10) + k25 .* x(3);
dx_dt(8) = k5 .* x(9) + k28 .* x(6) - k6.*x(8) - k7 .*x(8).*x(10);
dx_dt(9) = k20.*x(11) + k6 .* x(8) + k10 .*x(7) - k5 .* x(9) - k18 .* x(1) .* x(9)- k9 .* x(9) .* x(10) + k2 .* x(5) + k24 .* x(5);
dx_dt(10) = k10 .* x(7)+ k11 .* x(3) .* (x(13).^ k14)./ (k26 ^ k14 + x(13).^ k14)- k8 .*x(4) .* x(10) - k7 .* x(8) .* x(10) - k9 .* x(9) .* x(10) + k28 .* x(6) - k13 .* x(5) .* x(10)+ k16 .* x(2);
dx_dt(11) = k3 .*x(5) .* (x(14) + x(15)) - k20 .* x(11) - k30 .* x(11);
dx_dt(12) = k2 .* x(5) + k12 .* x(1) + k20 .* x(11) - k27 .* x(12);
dx_dt(13) = k15 .* (L-x(13));
dx_dt(14) = k1 .* ((k21 .* x(10).^2)./(k22^2 + x(10).^2) - x(14));
dx_dt(15) = k19 .* ((k23 .* x(10).^2)./(k29^2 + x(10).^2)- x(15));

%transpose dx_dt 
dx_dt = dx_dt';
return

0 个答案:

没有答案