Attached is a sample of my data that I would like to plot. I would like to use for loop to automate plotting from the timetable directly. Below is my code, however, it seems there is some problem. any thoughts would be appreciated. I would also like to get a handle to enhance the plot further.
for ii=1:2
plot(TT2.Date,TT2.(:,ii))
end

 採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 23 日
編集済み: Walter Roberson 2017 年 12 月 23 日

0 投票

plot(TT2.Date, TT2{:,ii})
... and remember the "hold on"

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2017 年 12 月 28 日

0 投票

I imagine that
plot(TT2.Date,TT2{:,1:2})
would also work. And if there's only two variables in your timetable, that's equivalent to
plot(TT2.Date,TT2.Variables)
where "Variables" is the default name to use, but it's whatever TT2.Properties.DimensionNames{2} is set to.

2 件のコメント

Hydro
Hydro 2017 年 12 月 28 日
Thanks Peter. There are a number of variables (~10). It would be very inconvenient to plot them one by one, that's why I want to use the loop to automate the plotting.
Peter Perkins
Peter Perkins 2018 年 1 月 5 日
You only think you want a loop. This
plot(TT2.Date,TT2{:,1:2})
plots them both at once, without a loop.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by