Extract values from ODE45
function [] = Example2()
clc
clear
close all
y0 = [100.; 0; 0]; % Initial values for the dependent variables
tspan= linspace(0,20,50);
options = optimset(‘display’,’off’);
[t,x]= ode45(@ODEfun,tspan,y0,options);
plot(t,x)
legend(‘Fa’,’Fb’,’Fc’)
end
function dYdv = ODEfun(v,s);
Fa = s(1);
Fb = s(2);
Fc = s(3);
Kc = 0.01;
Ft = Fa + Fb + Fc;
Co = 1;
K = 10;
Kb = 40;
ra = 0 – (K * Co / Ft * (Fa – (Co ^ 2 * Fb * Fc ^ 2 / (Kc * Ft ^ 2))));
Ka = 1;
Ra = Ka * Co * Fa / Ft;
Rb = Kb * Co * Fb / Ft;
dFadv = ra – Ra;
dFbdv = 0 – ra – Rb;
dFcdv = -2 * ra;
dYdv = [dFadv; dFbdv; dFcdv];
end
How Do I extract the values of Ra and Rb and plot them ?function [] = Example2()
clc
clear
close all
y0 = [100.; 0; 0]; % Initial values for the dependent variables
tspan= linspace(0,20,50);
options = optimset(‘display’,’off’);
[t,x]= ode45(@ODEfun,tspan,y0,options);
plot(t,x)
legend(‘Fa’,’Fb’,’Fc’)
end
function dYdv = ODEfun(v,s);
Fa = s(1);
Fb = s(2);
Fc = s(3);
Kc = 0.01;
Ft = Fa + Fb + Fc;
Co = 1;
K = 10;
Kb = 40;
ra = 0 – (K * Co / Ft * (Fa – (Co ^ 2 * Fb * Fc ^ 2 / (Kc * Ft ^ 2))));
Ka = 1;
Ra = Ka * Co * Fa / Ft;
Rb = Kb * Co * Fb / Ft;
dFadv = ra – Ra;
dFbdv = 0 – ra – Rb;
dFcdv = -2 * ra;
dYdv = [dFadv; dFbdv; dFcdv];
end
How Do I extract the values of Ra and Rb and plot them ? function [] = Example2()
clc
clear
close all
y0 = [100.; 0; 0]; % Initial values for the dependent variables
tspan= linspace(0,20,50);
options = optimset(‘display’,’off’);
[t,x]= ode45(@ODEfun,tspan,y0,options);
plot(t,x)
legend(‘Fa’,’Fb’,’Fc’)
end
function dYdv = ODEfun(v,s);
Fa = s(1);
Fb = s(2);
Fc = s(3);
Kc = 0.01;
Ft = Fa + Fb + Fc;
Co = 1;
K = 10;
Kb = 40;
ra = 0 – (K * Co / Ft * (Fa – (Co ^ 2 * Fb * Fc ^ 2 / (Kc * Ft ^ 2))));
Ka = 1;
Ra = Ka * Co * Fa / Ft;
Rb = Kb * Co * Fb / Ft;
dFadv = ra – Ra;
dFbdv = 0 – ra – Rb;
dFcdv = -2 * ra;
dYdv = [dFadv; dFbdv; dFcdv];
end
How Do I extract the values of Ra and Rb and plot them ? ode45, outputfcn MATLAB Answers — New Questions