Accuracy of the first derivative with ode45

조회 수: 1 (최근 30일)
I G
I G 2018년 7월 3일
댓글: I G 2018년 7월 4일
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?

답변 (1개)

Torsten
Torsten 2018년 7월 3일
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
James Tursa
James Tursa 2018년 7월 3일
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
I G 2018년 7월 4일
This works. Thanks a lot!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by