- #1
adschutte
- 1
- 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.
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.