then the blue curve shows Finite differences of a complex function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Benjamin Bauer
le 10 Juil 2020
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).
then the blue curve shows 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.
Réponses (1)
Steven Lord
le 10 Juil 2020
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 commentaires
Voir également
Catégories
En savoir plus sur Fit Postprocessing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!