dt = days(30);
TT2 = retime(TT1,'regular','next','TimeStep',dt);
T = timetable2table(TT2);
[C,IA,IC] = unique(T.Var1,'first');
B = sortrows(T(IA,:));
B=B(~any(ismissing(B),2),:);
daynumbers = floor(datenum(B.Time));
non_zero_X=[daynumbers/365];
non_zero_Y=[B.Var1];
M=polyfit(non_zero_X,non_zero_Y,1);
y1 = polyval(M,non_zero_X);
cc(m,1)=M(1);
cc(m,2)=M(2);
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/652543-calculating-per-year-slope-using-daily-time-series-data#comment_1145163
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/652543-calculating-per-year-slope-using-daily-time-series-data#comment_1145163
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/652543-calculating-per-year-slope-using-daily-time-series-data#comment_1147828
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/652543-calculating-per-year-slope-using-daily-time-series-data#comment_1147828
Sign in to comment.