필터 지우기
필터 지우기

diff vs. gradient

조회 수: 57 (최근 30일)
Benjamin
Benjamin 2018년 11월 5일
편집: Matt J 2018년 11월 5일
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

채택된 답변

Matt J
Matt J 2018년 11월 5일
편집: Matt J 2018년 11월 5일
gradient uses central differences while diff(x) uses right-hand differences x(i+1)-x(i).
  댓글 수: 12
Star Strider
Star Strider 2018년 11월 5일
Yes!
Matt J
Matt J 2018년 11월 5일
편집: Matt J 2018년 11월 5일
If the X-data are not equi-spaced, use diff().

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by