MATLAB: Subset time series plot

subset time series

I have a time series plot (y). I want divide the time series into subsets and subsequently extract the subsets separately. In other word, I want to divide the time series plot into equal chunks.

Best Answer

t = 0:0.001:10;
x = 0.2*cos(t) + cos(1.4*t) + 0.8*cos(5.2*t) + 0.02*randn(1, 10001);
N = 7; % Number of divisions
I = 1:ceil(numel(t)/N):numel(t);
if (I(end) ~= numel(t))
I = [I numel(t)];
end
for j = 1:N
Y{j,1} = [t(I(j):I(j+1))' x(I(j):I(j+1))'];
end
Here, Y is a cell array where every cell has the T and x subsections.
Related Question