Calculating trend rate of change

83 views (last 30 days)
Maja Zdulska on 26 Jan 2021
Commented: Maja Zdulska on 26 Jan 2021
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?
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
%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 on 26 Jan 2021
Edited: Bart Kieviet on 26 Jan 2021
I guess you mean the derivative? It's the function
diff
More on this function here.
Maja Zdulska on 26 Jan 2021
Ah, I wasn't sure whether I could just do it like that. Thanks a lot!