Convert datetime to time of day, to be able to plot along time (e.g. 08:00, 10:00, 12:00 14:00...)
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have data in this format:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168364/image.png)
- I want to convert the datetime into the time only (in HH:mm) to be able to plot the temperature along the time of the day.
My goal is to produce this graph, but just for one whole day:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168367/image.png)
4 个评论
Walter Roberson
2018-1-4
The ability to use datatime or duration objects for the axes is new in R2016b. Which MATLAB version are you using?
回答(1 个)
Neil Guertin
2018-1-4
Use the timeofday function to convert your datetime objects to duration objects. You should be able to use the duration objects on the x axis just as you would use datetime objects. If you are not able to, please post the error message you are seeing.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!