Date String to x-axis on Plot, Date and Time on Plots

2 次查看(过去 30 天)
I need to plot time on a graph in matlab. From my excel sheet, I have the data imported in a number value. In other words, the excel sheet shows serial numbers for dates before it is even imported.
Then I took this column of serial numbers, and converted it to dates using datestr(x).
However, you cannot plot strings. How can I fix this situation to plot(x,y) where x is in dd/mm/yyyy HH:MM:ss format?

回答(1 个)

dpb
dpb 2015-6-2
Which release? If late, see
If you're on an earlier release which doesn't support the datetime object, then
doc datetick % and friends
  2 个评论
Peter Perkins
Peter Perkins 2015-6-3
As dpb says, if you're using R2014b or later, use datetimes. To convert from Excel serial day numbers to datetime, use
d = datetime(exelDates,'convertFrom','excel');
Or if you have MATLAB serial datenums, use 'convertFrom','datenum'.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by