Passing computations from ODE45

  • Thread starter Thread starter adschutte
  • Start date Start date
  • Tags Tags
    Ode45
Click For Summary
SUMMARY

This discussion focuses on passing computed variables from the user-defined function in MATLAB's ODE45. The user seeks a method to output the variable Fc, calculated within the function DiffEQ, without recomputing it after the ODE45 execution. Suggestions include saving the variable to a file or integrating it into a larger code structure to maintain efficiency and avoid redundant calculations.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of ODE45 function usage
  • Knowledge of user-defined functions in MATLAB
  • Basic concepts of differential equations
NEXT STEPS
  • Explore MATLAB's file I/O functions for saving variables
  • Learn about MATLAB's global variables for sharing data between functions
  • Investigate the use of nested functions in MATLAB for variable access
  • Review MATLAB documentation on ODE45 for advanced options and configurations
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly engineers and scientists working with differential equations, as well as developers looking to optimize their ODE computations.

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.
 
Computer science 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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K