Matlab ode45/independent variables help

In summary, you can use ode45 to solve a system of ODEs with two independent variables by reformulating it as a PDE and using standard numerical techniques. Additional resources on PDEs and finite difference methods are available for further guidance.
  • #1
CaptainEvil
99
0
Hi - I'm having some difficulties with a simulation I'm writing. I have a second order ODE with three arguments of derivative information y(1),y(2),y(3) - each changing wrt to the independent variable t.


Currently, in my system of ODEs, I have a variable that I am treating as constant. Ideally, I would like this constant to change with respect to another variable that is not t. Is there a way to use ode45 to combine two independent variables into one system of ODEs to solve simultaneously?

can provide code if requested. Thanks
 
Physics news on Phys.org
  • #2
in advance!Yes, you can use ode45 to solve a system of ODEs that have two independent variables. To do this, you will need to reformulate your system of ODEs as a partial differential equation (PDE). This PDE can then be solved using standard numerical techniques such as finite differences or finite element methods. For more information on how to do this, please see the following resources: 1. https://en.wikipedia.org/wiki/Partial_differential_equation 2. http://www.johndcook.com/blog/2009/06/26/finite-difference-example-heat-equation/ 3. http://www.numerical-tutorials.com/pde/finite-differences.php
 

1. What is ode45 in Matlab?

Ode45 is a built-in function in Matlab that solves ordinary differential equations (ODEs) using a variable-step Runge-Kutta method. It is commonly used in scientific and engineering applications to model dynamic systems.

2. How do I use ode45 in Matlab?

To use ode45, you need to define the ODEs in a separate function file and provide the necessary inputs such as initial conditions and time span. Then, you can call the ode45 function with the appropriate arguments to solve the ODEs and obtain the numerical solution.

3. What are the independent variables in ode45?

The independent variable in ode45 is typically time, which represents the time span over which the ODEs are solved. However, you can also use other independent variables in your ODEs as long as they are properly defined in the ODE function file.

4. Can I change the step size in ode45?

Yes, you can change the step size in ode45 by specifying the 'MaxStep' option when calling the function. This allows you to control the accuracy of the solution and the computation time. Alternatively, you can also use the 'RelTol' and 'AbsTol' options to specify the relative and absolute error tolerances.

5. How do I plot the results from ode45?

To plot the results from ode45, you can use the 'odeplot' function or simply use the built-in 'plot' function in Matlab. The solution obtained from ode45 is a vector of values, so you can plot it against the independent variable to visualize the behavior of the system over time.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
951
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top