Get the derivative with MATLAB ode45

In summary, the conversation is about solving a differential equation with MATLAB ode45 and finding a convenient method to get the derivative of y. It is suggested to plug in values for t and y or use the diff command, but it may slow down computation when doing the integration and differentiation."
  • #1
albertshx
13
0
Hello every one!
I'm trying to solve a differential equation y' = f(t,y) with MATLAB ode45. Besides the original y, y' is also very useful to me. But I simply don't know how to get it. Is there any convenient method to do this? Or what I can do is just to compute y in many point and use diff? Thank you very much!
 
Physics news on Phys.org
  • #2
Well, you do have the function for y' already. You define it to use with MATLAB's ode45. You could just plug in values for t and y. You could also use the diff command to get your specific y' from y, but that somehow seems like a waste to do the integration and then differentiate again.
 
  • #3
Thanks and I get your idea. For I need to do integral with y, I'm concerned that whether computing y in many data points would slow down the computation.
 

1. What is the purpose of using MATLAB ode45 to get the derivative?

MATLAB ode45 is a function that is used to numerically solve ordinary differential equations (ODEs). Its purpose is to calculate the derivative of a given function at a specific point or set of points. This allows for the simulation of complex systems and the analysis of their behavior over time.

2. How does MATLAB ode45 calculate the derivative?

MATLAB ode45 uses a combination of fourth and fifth order Runge-Kutta methods to calculate the derivative. These methods involve breaking the interval of interest into smaller sub-intervals and using a weighted average of the slopes at different points within each sub-interval to approximate the derivative.

3. What are the inputs and outputs of MATLAB ode45?

The inputs of MATLAB ode45 are the function to be evaluated, the initial conditions, and the time interval of interest. The output is an array of values representing the derivative of the function at each point within the time interval.

4. How accurate is the derivative calculated by MATLAB ode45?

MATLAB ode45 is a highly accurate method for calculating derivatives. It has an error tolerance of 1e-6, meaning that the calculated values will be within 0.000001 of the true solution. This error tolerance can be adjusted by the user to fit the requirements of their specific problem.

5. Can MATLAB ode45 be used for systems of differential equations?

Yes, MATLAB ode45 can be used to solve systems of differential equations. It can handle both first-order and higher-order systems, and the input function can be written to accommodate multiple variables. Additionally, MATLAB has several other ODE solvers, such as ode23 and ode15s, which may be better suited for specific types of systems.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
987
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
866
Back
Top