Finite differences of a complex function
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a function (a complex array of values uul(:)) for which I would like to compute its derivative. I simply use central finite differences
uulder=(uul(3:end)-uul(1:end-2))./deltaeta(2:end-1)'/2;
uulderabs=(abs(uul(3:end))-abs(uul(1:end-2)))./deltaeta(2:end-1)'/2;
I plot this:
>> plot(eta,abs(uul))
>> hold on
>> plot(eta(1:end-2),abs(uulder))
>> hold on
>> plot(eta(1:end-2),uulderabs)
It seems the red curve is incorrect while the yellow one is correct. However, I would need the vector whose absolute value gives the yellow curve (and not taking absolute values beforehand like with uulderabs). I need this because with the yellow curve I am losing the real and imaginary parts and I would like to be able to use them. What is it that I am doing wrong?
댓글 수: 1
Benjamin Bauer
2020년 7월 10일
What exactly makes you think the red curve is incorrect?
Note that the red curve's values are not supposed to match the tangent slopes of the blue one: If we say the values in uul are evaluated from a function then the blue curve shows and the red curve shows which is definitely not the same as (displayed by the yellow curve).
However, if you still want some graphical validation of your derivatives you should try to plot
absuulder = real(uul.*conj(uulder))./abs(uul)
which should match the yellow curve.
답변 (1개)
Steven Lord
2020년 7월 10일
For real numbers, the operators ' and .' give the same result.
xR = 1:10;
y1R = xR'
y2R = xR.'
isequal(y1R, y2R)
For complex numbers, they don't.
xC = complex(1:10, 10:-1:1);
y1C = xC'
y2C = xC.'
isequal(y1C, y2C)
See the documentation for either transpose or ctranspose for a brief explanation of the difference between the two.
I suspect your deltaeta is complex.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!