how do I plot time data (recorded in secods) in hh:mm:ss format?
Show older comments
I have a vector of time stamps - recorded in seconds from the beginning of the record. I want use the time stamps to plot a time series of some other data. I would like to label the x axis in hh:mm:ss format (as opposed to what I have now, where the x axis simply goes from 1:n seconds).
Answers (3)
Peter Perkins
on 24 Apr 2015
Edited: Peter Perkins
on 24 Apr 2015
If you're using MATLAB R2014b or later, one of these is what you're looking for:
1) plot the actual elapsed times as hh:mm:ss -
t = seconds(1:5)
y = 1:5;
plot(t,y,'DurationTickFormat','hh:mm:ss')
or plot realtime as hh:mm:ss -
t0 = datetime(2015,4,24)
t = 1:5;
t = t0 + seconds(t)
plot(t,y,'DatetimeTickFormat','HH:mm:ss')
Hope this helps.
test testting
on 24 Jun 2019
1 vote
I hope people does not write code that has not been tested! It's a great waste of time to read all the nonsense!
Star Strider
on 22 Apr 2015
0 votes
Use the datetick function.
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!