Get the derivative with MATLAB ode45

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 6K views
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.