Passing computations from ODE45

  • Thread starter Thread starter adschutte
  • Start date Start date
  • Tags Tags
    Ode45
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
1 reply · 3K views
adschutte
Messages
1
Reaction score
0
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.
 
Physics news on Phys.org
Save it in a file or embed the code in a bigger one. Is not very consuming to do an ode45.