Managing alot of variables (time series)

I have a lot of time series that are of different sizes(k x 1) so i cant make one big matrix with them. im trying to calculate different measures (autocorrelations etc). how can i do a loop to go through each time series instead of writing a line of code for each time series ?
thanks

 Accepted Answer

You can use a cell array. For example
y={[1;2;3;4], [2;6;8], [0;1;0;0;1;0;1]}
for k=1:numel(y)
v=y{k}
m{k}=mean(v) % just an example
end

1 Comment

[Jim commented]
had no idea about cell arrays worked out great thanks !

Sign in to comment.

More Answers (1)

* *Sorry to bother again but im at a loss, can anyone help explain why the array for variable RHOS wont work ? its a very simple line i dont understand why only the last value works* *_
%calculer autocovariance(1)
for i=1:numel(CIE);
gammas{i}=sum((CIE{i}(1:N{i}-1)-means{i}).*(CIE{i}(2:N{i})-means{i}))/N{i};
end
_
%calculer autocorrelation(1)
for i=numel(CIE);
rhos{i}= gammas{i}/(stdev{i}^2)
end
rhos =
[] [] [] [] [0.1937]

2 Comments

This line
for i=numel(CIE);
should be
for i=1:numel(CIE);
Could you check the gammas cell first. I think this problem comes from there.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements 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!