Clear Filters
Clear Filters

Calculating trend rate of change

45 views (last 30 days)
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,
%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
%define variables
figure (1)
xlabel('\bf Year')
ylabel('\bf Wind speed (m/s)')
grid on
hold on
%fit a trendline to the data
%this bit tests the trend for significance with Mann-Whitney
%if p is very small and h=1, trend is significant

Accepted Answer

Bart Kieviet
Bart Kieviet on 26 Jan 2021
Edited: Bart Kieviet on 26 Jan 2021
I guess you mean the derivative? It's the function
More on this function here.
Bart Kieviet
Bart Kieviet on 26 Jan 2021
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 on 26 Jan 2021
Ah, I wasn't sure whether I could just do it like that. Thanks a lot!

Sign in to comment.

More Answers (0)


Find more on Preprocessing Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!