필터 지우기
필터 지우기

discrete deriviative has wrong sign

조회 수: 3 (최근 30일)
Niles Martinsen
Niles Martinsen 2015년 4월 8일
답변: Adam 2015년 4월 8일
I have the following MWE that calculates the derivative of a function along the y-direction:
x=1:50;
y=x;
phi = sin((x-10)/10);
dyPhi = (4.0*(circshift(phi(:,:), [+0, +1]) - circshift(phi(:,:), [+0, -1])) + ...
1.0*(circshift(phi(:,:), [+1, +1]) - circshift(phi(:,:), [-1, -1])) + ...
1.0*(circshift(phi(:,:), [-1, +1]) - circshift(phi(:,:), [+1, -1])))/12.0;
figure(1)
imagesc(phi)
colorbar
figure(2)
imagesc(dyPhi)
colorbar
However, please take a look at the two plots: On the plot for dyPhi, it seems that the derivative has a wrong sign.
Why is that? If I swap the sign, then I get what I would expect.

답변 (1개)

Adam
Adam 2015년 4월 8일
At a guess I would say it is because circshift shifts in the opposite direction to what you would expect. Certainly that catches me quite often when I have to shift by -1 when I intuitively thought it should be +1

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by