3-d order derivative

조회 수: 4 (최근 30일)
Max Demesh
Max Demesh 2022년 2월 13일
댓글: Matt J 2022년 2월 14일
Dear all,
there is the following problem with the calculation of a 3-d order derivative.
I have two vectors of lambda and refractive index, respectively. I take the 3-d order derivative using a gradient().
dndl=gradient(n)./gradient(lambda);
d2ndl2=gradient(dndl)./gradient(lambda);
d3ndl3=gradient(d2ndl2)./gradient(lambda);
When I use a relatively small number of points (for example 3000) , I get a smooth plot.
In the case of more points (30 000) there is some oscillation in the plot.
What is the reason of such behavior?
Thank you a lot.
  댓글 수: 2
Matt J
Matt J 2022년 2월 13일
What do you mean by "use more points"? If it's a different input array why expect the same results?
Max Demesh
Max Demesh 2022년 2월 13일
What do you mean by "use more points"?
I mean, that I make the differences smaller and increase the accuracy.
Moreover, if I find the analytical function and then take the 3-d order derivative, I obtain smooth plots in any case.

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

답변 (3개)

Catalytic
Catalytic 2022년 2월 13일
If the points are too close together, the difference between neighbours will be so small as to be dominated by floating point errors
  댓글 수: 1
Max Demesh
Max Demesh 2022년 2월 13일
It seems to be true. Using non SI base units do not help.
I guess in this case there is no way to solve this issue.
P.S. For the 2-nd derivative there is no problem for any number of points.

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


Matt J
Matt J 2022년 2월 13일
You could try diff(x,3)
  댓글 수: 2
Max Demesh
Max Demesh 2022년 2월 14일
It does not work too, because diff() uses a forward difference, but the gradient() uses a central difference.
Matt J
Matt J 2022년 2월 14일
Why care whether its forward or central? For a smooth curve, it should work out the same.

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


Max Demesh
Max Demesh 2022년 2월 14일

카테고리

Help CenterFile Exchange에서 Spatial Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by