Solving ODEs with MATLAB: Specifying Time & y Values

In summary, the conversation discussed the use of ODE solvers in Matlab and the need for specifying the input as either time or y value for the dy/dt problem. It was clarified that ODEs can only have one variable, which in this case is t, and the importance of providing the initial value of y at time 0 for a single solution.
  • #1
NoobixCube
155
0
Anyone have much knowledge on the ODE solvers in matlab? I have an ODE and I want to specificy whether the input is time or the y value for the dy/dt problem.
 
Physics news on Phys.org
  • #2
Could you please be more specific.
You can only have one variable in an ODE and in this case that variable is t, i.e. the equation is

dy/dt=f(t)

where f is some function of t (and ONLY of t, otherwise it is a PDE).
In order to have a single solution to this ODE you then only need the initial value of y at time 0, i.e. y(0).
 
  • #3
Cool thanks I think that's what I was looking for.
 

1. How do I specify the time and y values in MATLAB when solving ODEs?

To specify the time and y values in MATLAB, you can use the "ode45" function. This function takes in the differential equation, initial conditions, and a time span as inputs. You can specify the time span using the "linspace" function, which creates a vector of evenly spaced time points. The initial conditions are specified as a vector, with the first element representing the initial time and the remaining elements representing the initial values of the dependent variables.

2. Can I solve a system of ODEs using MATLAB?

Yes, you can solve a system of ODEs using MATLAB. The "ode45" function can handle systems of up to six differential equations. If your system has more than six equations, you can use the "ode15s" function, which is better suited for stiff systems.

3. How do I plot the solution to an ODE in MATLAB?

To plot the solution to an ODE in MATLAB, you can use the "plot" function. The output of the "ode45" function is a structure that contains the time and y values at each time point. You can use these values to create a plot by specifying the time as the x-axis and the corresponding y values as the y-axis.

4. What is the difference between "ode45" and "ode15s" in MATLAB?

The main difference between "ode45" and "ode15s" in MATLAB is that "ode45" uses a non-stiff solver, while "ode15s" uses a stiff solver. Stiff systems are those where the solution changes rapidly over a small time interval, and non-stiff systems are those where the solution changes gradually over a larger time interval. It is important to choose the appropriate solver depending on the stiffness of your system to ensure accurate results.

5. Can I specify additional options when using the "ode45" function in MATLAB?

Yes, you can specify additional options when using the "ode45" function in MATLAB. For example, you can set the maximum and minimum time step sizes, the maximum number of time steps, and the error tolerance. These options can be specified using the "odeset" function before calling the "ode45" function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
22
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
978
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
675
Back
Top