How do you calculate percentage change between sequential elements in array?

조회 수: 11 (최근 30일)
I have a 14400x11 array of values from the output of a hyperbolic function and want to calculate the sequential percentage change from, for example, the first element in the first row and column a(i,j) to the second element in the second row and first column a(i+1,j). How can I do this?

채택된 답변

A Jenkins
A Jenkins 2014년 6월 20일
X=rand(3,4)
percent_change=diff(X)./X(1:end-1,:)

추가 답변 (1개)

dpb
dpb 2014년 6월 20일
pct=100*diff(a(:,1))./a(1:end-1,1);

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by