MATLAB Get the derivative with MATLAB ode45

AI Thread Summary
To solve the differential equation y' = f(t,y) using MATLAB's ode45, the original function for y' is already defined within the ode45 framework. Users can directly evaluate y' by plugging in values for t and y. While it is possible to compute y at multiple points and then use the diff command to derive y', this approach may be inefficient since it involves integrating and then differentiating again. Concerns about computational efficiency arise when considering the need for multiple data points to compute y, as this could slow down the overall process.
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

Back
Top