Last active
April 14, 2017 19:08
-
-
Save lxm1117/b039a742d5e6e2ed544dfb91966515df to your computer and use it in GitHub Desktop.
matlab ode45 rxns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rxn.m | |
| function dydt = rxn( t,y ) | |
| %UNTITLED Summary of this function goes here | |
| % Detailed explanation goes here | |
| k1=260;k1_r=4000; | |
| dydt1=-k1*y(1)*y(2)+k1_r*y(3); | |
| dydt2=-k1*y(1)*y(2)+k1_r*y(3); | |
| dydt3=k1*y(1)*y(2)-k1_r*y(3); | |
| dydt=[dydt1;dydt2;dydt3]; | |
| end | |
| //////// | |
| t=0:0.01:1; | |
| y_init=[1000/602/0.125,800/602/0.125,0]; | |
| y_init=y_init'; | |
| [t,y]=ode45(@rxn,t,y_init) | |
| //////// | |
| function dydt = rxn( t,y ) | |
| %UNTITLED Summary of this function goes here | |
| % Detailed explanation goes here | |
| k1=260;k1_r=4000; | |
| k2=9.6;k2_r=70; | |
| dydt1=-(k1+k2)*y(1)*y(2)+k1_r*y(3)+k2_r*y(4); | |
| dydt2=-(k1+k2)*y(1)*y(2)+k1_r*y(3)+k2_r*y(4); | |
| dydt3=k1*y(1)*y(2)-k1_r*y(3); | |
| dydt4=k2*y(1)*y(2)-k2_r*y(4); | |
| dydt=[dydt1;dydt2;dydt3;dydt4]; | |
| end | |
| ///////// | |
| t=0:0.1:100; | |
| y_init=[1000/602/0.125,800/602/0.125,0,0]' | |
| [t,y]=ode45(@rxn,t,y_init); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %% no explicit expression | |
| syms x(t) A(t) AB(t) | |
| kf=1;kb=1; | |
| ode1=diff(AB)==kf*A*x-kb*AB; | |
| ode2=diff(A)==-kf*A*x+kb*AB; | |
| ode3=diff(x)==-kf*A*x+kb*AB; | |
| odes=[ode1;ode2;ode3]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function dydt = rxn( t,y ) | |
| %UNTITLED Summary of this function goes here | |
| % Detailed expl anation goes here | |
| % x(t) + A <-> AB | |
| % y(1)=AB; y(2)=A; y(3)=x(t) | |
| k1=260;k1_r=0; | |
| dydt1=k1*y(2)*y(3)-k1_r*y(1); | |
| dydt2=-k1*y(2)*y(3)+k1_r*y(1); | |
| dydt3=-k1*y(2)*y(3)+k1_r*y(1)+10*sin(2*pi*t); | |
| dydt=[dydt1;dydt2;dydt3]; | |
| end | |
| /// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment