‘How Do I extract the values of Ra and Rb and plot them ?’
You don’t ‘extract’ them. Just recalculate them from the integrated values.
Make a few changes to your ‘Example2’ function:
function [] = Example2()
y0 = [100.; 0; 0];
tspan= linspace(0,20,50);
options = optimset('display','off');
[t,x]= ode45(@ODEfun,tspan,y0,options);
figure
plot(t,x)
legend('Fa','Fb','Fc')
Fa = x(:,1);
Fb = x(:,2);
Fc = x(:,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;
figure
plot(t, [Ra Rb])
legend('R_a', 'R_b')
end
This will produce the plot you want. You could plot them in the same figure as the first plot (using the hold function), however you will likely not be able to see them well. I would use separate plots.
Best Answer