Using for loop for plotting from a timetable?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2017-12-23
编辑:Walter Roberson
2017-12-23
plot(TT2.Date, TT2{:,ii})
... and remember the "hold on"
0 个评论
更多回答(1 个)
Peter Perkins
2017-12-28
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 个评论
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!