Get the derivative with MATLAB ode45

Click For Summary
SUMMARY

The discussion focuses on solving the differential equation y' = f(t,y) using MATLAB's ode45 function. Users can directly obtain the derivative y' by defining it within the function used for ode45, eliminating the need for post-processing with the diff command. While using diff on computed y values is an option, it is inefficient as it requires additional computation after integration. Concerns about computational speed when evaluating y at multiple data points are also addressed.

PREREQUISITES
  • Understanding of differential equations and their representations.
  • Familiarity with MATLAB programming and syntax.
  • Knowledge of MATLAB's ode45 function for numerical integration.
  • Basic understanding of the diff command in MATLAB for numerical differentiation.
NEXT STEPS
  • Explore MATLAB's ode45 documentation for advanced usage and options.
  • Learn about MATLAB's numerical differentiation techniques beyond the diff command.
  • Investigate performance optimization strategies for MATLAB computations.
  • Study the implications of evaluating functions at multiple data points in numerical methods.
USEFUL FOR

Mathematics students, engineers, and researchers who are solving differential equations using MATLAB and require efficient methods for obtaining derivatives.

albertshx
Messages
13
Reaction score
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
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.
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 5 ·
Replies
5
Views
4K