Accuracy of the first derivative with ode45
Mostra commenti meno recenti
I am using ode45 to get solution of system with 4 differential equation of the first order. ode45 gives me result as value, but I need the first derivative of that value. So, I found two methods to do that.
First one, is the gradient command. The second one is sol and deval commands together. My question is, which of these two methods will give me more accurate result? And which of these two methods will give me accuracy of result same as accuracy of ode45?
Risposte (1)
Torsten
il 3 Lug 2018
2 voti
The most accurate method is to use the derivatives you set by yourself in the function routine that ODE45 calls (the dydt(i) values).
Best wishes
Torsten.
5 Commenti
James Tursa
il 3 Lug 2018
Modificato: James Tursa
il 3 Lug 2018
Please post the code you are using. Basically, you simply pass the result that ode45 is giving you back into your derivative function that you wrote. If this function is not vectorized then you will have to call it in a loop.
James Tursa
il 3 Lug 2018
Your derivative function is not vectorized, so you need to call it in a loop. E.g.,
dp = zeros(size(pv));
for k=1:size(pv,1)
dp(k,:) = fun(zv(k),pv(k,:));
end
I G
il 4 Lug 2018
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!