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

Passing computations from ODE45

  1. Jun 27, 2007 #1
    Does anyone know a trick to pass variables computed in the user defined function called by ODE45 in MATLAB?

    For example, imagine you have the following code:

    [t,y] = ode45('DiffEQ',dt,Initial,options);

    function dy = DiffEQ(t,y)
    Fc = y(1)*y(2);
    dy(1) = y(2);
    dy(2) = -k*y(1)-c*y(2)+Fc;

    How can we pass Fc as an output? I don't want to re-compute Fc with the solutions. Thanks for any tips.
  2. jcsd
  3. Jun 27, 2007 #2
    Save it in a file or embed the code in a bigger one. Is not very consuming to do an ode45.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook