필터 지우기
필터 지우기

Calculating trend rate of change

조회 수: 24 (최근 30일)
Maja Zdulska
Maja Zdulska 2021년 1월 26일
댓글: Maja Zdulska 2021년 1월 26일
Hi everyone,
I'm currently analysing a time series of data (see code below). I've fitted a trendline into it but I would like to calculate its rate of change per year. Any ideas how can it be done?
Thanks in advance,
Maja
%script to plot year-by-year data points for the full basin, fit a
%trendline and test it for significance with Mann-Whitney U test
%load data
data=readtable('Mydata.csv');
%define variables
year=data{:,1};
wind=data{:,8};
figure (1)
plot(year,wind,'b','LineWidth',1.2)
xlabel('\bf Year')
ylabel('\bf Wind speed (m/s)')
grid on
hold on
%fit a trendline to the data
wind_coeff=polyfit(year,wind,1);
wind_trend=polyval(wind_coeff,year);
plot(year,wind_trend,'r--','LineWidth',1.2);
%this bit tests the trend for significance with Mann-Whitney
%if p is very small and h=1, trend is significant
[p,h]=ranksum(year,netwind);

채택된 답변

Bart Kieviet
Bart Kieviet 2021년 1월 26일
편집: Bart Kieviet 2021년 1월 26일
I guess you mean the derivative? It's the function
diff
More on this function here.
  댓글 수: 3
Bart Kieviet
Bart Kieviet 2021년 1월 26일
If I understand correctly you have a year-by-year numbers, so say:
year = [2010, 2011, 2012, 2013];
wind = [10, 15, 5, 16];
if I run diff, I get:
df = diff(wind); % [5, -10, 11]
I could use mean to get the average:
mean( df ); % 2
Maja Zdulska
Maja Zdulska 2021년 1월 26일
Ah, I wasn't sure whether I could just do it like that. Thanks a lot!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Preprocessing Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by