Solving ODEs with Modeling & Matlab

  • Context: MATLAB 
  • Thread starter Thread starter Deuterio
  • Start date Start date
  • Tags Tags
    Matlab Modeling
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
Deuterio
Messages
2
Reaction score
0
I'm modeling a chemical reactor and I have to solve a system of ODE's like that:

dX/dV = a*X
dT/dV = b*(dX/dV) - c*(T-T0)

I've been a Matlab user for so long but I've never seen a solution of this kind of system. I've tried to solve using ode45 but it didn't work. I've searched in books and/or homepages about Matlab and I haven't found any tip.
If some one here could help me I'd be so grateful.

Thanks
 
Physics news on Phys.org
I may be a little rusty, but I think if you define your state as:
s = [X, dX/dV, T, dT/dV], then you can use ode45 (or any other MATLAB ode solver). (I'm assuming you've used the solvers before and you're just having trouble with this problem.) So your derivative function will look something like this:

...
function sdot = deriv(V,S)
% Current values of state parameters
X = S(0);
dXdV = S(1);
T = S(3);
dTdV = S(4);

% Updated values of derivatives of state parameters
dXdV=a*X;
d2XdV2 = a*dXdV;
dTdV = b*(dXdV) - c*(T-T0);
d2TdV2 = b*d2XdV2 - c*dTdV;

sdot = [dXdV, d2XdV2, dTdV, d2TdV2];
 
You could put the system in a more standard form. i.e. replace the occurrence of dx/dv in the second equation with a*X, not to mention that I think you can probably solve it out by hand because the system is "triangular"
 
Thanks

Both options have worked properly.
Thanks for your help!