How to code difference quotients in matlab?

조회 수: 6 (최근 30일)
ekagra gupta
ekagra gupta 2022년 6월 13일
댓글: Image Analyst 2022년 6월 14일
I have a vector U and I want to take its difference quotient at a time instance j i.e. I want to find dU as shown below. How can it be done?
Thank you guys in advance!

채택된 답변

Jonas
Jonas 2022년 6월 13일
elementwise differences of consecutive elements can be calculated using diff() command
  댓글 수: 2
ekagra gupta
ekagra gupta 2022년 6월 13일
I tried but actually I need ratio of variance of these difference quotients. that is returning NaN values at some points.
Image Analyst
Image Analyst 2022년 6월 14일
U = randi(9, 1, 10)
U = 1×10
2 2 5 8 2 7 8 9 5 1
% Compute difference
du = diff(U)
du = 1×9
0 3 3 -6 5 1 1 -4 -4
% Compute variance
varU = var(du)
varU = 14.1111
Not sure what you mean by ratio. A ratio is a fraction of something divided by something. What are you ratioing? The ratio of a single number -- the variance -- doesn't make sense.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by