plotting time series

1 回表示 (過去 30 日間)
Richard
Richard 2012 年 3 月 30 日
Is it possible to use the timeseries command in a loop? I use the following code for producing a plot:
x = cell2mat(data{1}');
ts1 = timeseries(x,1:length(x));
ts1.TimeInfo.Units = 'hours';
ts1.TimeInfo.StartDate = ['01-Jan-' FirstYear{1}]; %
ts1.TimeInfo.Format = 'mmm dd, yyyy';
ts1.Time=ts1.Time-ts1.Time(1);
plot(ts1)
I want to run this in a loop, however when i try:
for i = 1:length(Year);
figure(i)
x{i} = cell2mat(data{i}');
ts1{i} = timeseries(x{i},1:length(x{i}));
... and so on the run fails. I receive the error:
Cell contents assignment to a non-cell array object.

採用された回答

Kye Taylor
Kye Taylor 2012 年 3 月 30 日
Just change the assignment in your loop from
ts1{i} = timeseries(x{i},1:length(x{i}));
to
ts1(i) = timeseries(x{i},1:length(x{i}));
note the parentheses instead of curly braces.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by