MATLAB Solving ODEs with Modeling & Matlab

  • Thread starter Thread starter Deuterio
  • Start date Start date
  • Tags Tags
    Matlab Modeling
AI Thread Summary
The discussion revolves around solving a system of ordinary differential equations (ODEs) related to a chemical reactor model using MATLAB. The user initially struggles with implementing the ODEs using the ode45 solver. A suggestion is made to redefine the state variables to include both the variables and their derivatives, which allows for a clearer formulation of the problem. The proposed derivative function is structured to compute the necessary derivatives based on the defined state variables. The user successfully implements the suggestions and reports that both proposed methods worked effectively to solve the system.
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 occurance 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!
 

Similar threads

Replies
7
Views
4K
Replies
1
Views
3K
Replies
7
Views
4K
Replies
1
Views
4K
Replies
10
Views
3K
Replies
2
Views
3K
Back
Top