%% Compute Long-Term Trend in Vector of Data Using SSA
% Compute the long-term trend in a vector of data using singular spectrum analysis.
% Create a vector of data A that contains a long-term trend, seasonal trend, and noise component.

t = (0:20)';
A = 3*sin(t) + t + 0.1*rand(21,1);

% Compute the long-term trend. Plot the data and the long-term trend.

LT = trenddecomp(A);
plot(t,A,t,LT)
legend("Data","Long-term")

% Copyright 2021 The MathWorks, Inc.