Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Modeling and Matlab

  1. Apr 23, 2006 #1
    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.

  2. jcsd
  3. Apr 23, 2006 #2


    User Avatar
    Science Advisor
    Gold Member

    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
    d2XdV2 = a*dXdV;
    dTdV = b*(dXdV) - c*(T-T0);
    d2TdV2 = b*d2XdV2 - c*dTdV;

    sdot = [dXdV, d2XdV2, dTdV, d2TdV2];
  4. Apr 24, 2006 #3
    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"
  5. Apr 28, 2006 #4

    Both options have worked properly.
    Thanks for your help!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook