- #1
Dr.D
- 2,412
- 720
- TL;DR Summary
- How do I define system constants once at the beginning of a script, and then have them available inside the function that calculates the derivatives for an ODE solution and also after solving the ODE?
I'm trying to do a fairly complete system analysis script in Octave that involves these steps:
1) Assign values to all fixed system parameters
2) Make various preliminary calculations based on system parameters
3) Solve a system of differential equations
4) Make various post-ODE solution calculations
5) Make various plots
I'd like to have all the results of the first two steps available for use in the last three steps. It would seem like a global declaration would be the way to do this, but the documentation on that is unclear.
How do I structure the code to accomplish these objectives? I really do not want to have to bury all the system parameters and related constants inside the function that defines the derivative. Surely there is a better way?
1) Assign values to all fixed system parameters
2) Make various preliminary calculations based on system parameters
3) Solve a system of differential equations
4) Make various post-ODE solution calculations
5) Make various plots
I'd like to have all the results of the first two steps available for use in the last three steps. It would seem like a global declaration would be the way to do this, but the documentation on that is unclear.
How do I structure the code to accomplish these objectives? I really do not want to have to bury all the system parameters and related constants inside the function that defines the derivative. Surely there is a better way?
Last edited: