Filter löschen
Filter löschen

diff vs. gradient

57 Ansichten (letzte 30 Tage)
Benjamin
Benjamin am 5 Nov. 2018
Bearbeitet: Matt J am 5 Nov. 2018
Why does:
diffpressure = gradient(pressure)./gradient(density);
and
diffpressure = diff(pressure)./diff(density);
give drastically different results? The derivative using each method are completely different. See attached figure

Akzeptierte Antwort

Matt J
Matt J am 5 Nov. 2018
Bearbeitet: Matt J am 5 Nov. 2018
gradient uses central differences while diff(x) uses right-hand differences x(i+1)-x(i).
  12 Kommentare
Star Strider
Star Strider am 5 Nov. 2018
Yes!
Matt J
Matt J am 5 Nov. 2018
Bearbeitet: Matt J am 5 Nov. 2018
If the X-data are not equi-spaced, use diff().

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by