How to get x-axis to be in seconds utilizing the timetick or comparable function

1 view (last 30 days)
I am plotting time on the x-axis using the datetick, however I want the x-axis to be seconds from the start of the day, ie., from 0 to 86400. I tried datetick('x', 'SS') and that was not an option. Anybody aware on how to get the x-axis in this manner?
start = (datenum('08-Feb-2019 07:32:50:503'));
stop = (datenum('08-Feb-2019 09:26:06:049'));
x = [start start stop stop];
y = [0 1 1 0];
figure; plot(x,y);
datetick('x', 'HH:MM:SS')

Answers (1)

dpb
dpb on 20 Mar 2019
tfmt='dd-MMM-yyyy HH:mm:ss:SSS';
start = datetime('08-Feb-2019 07:32:50:503','InputFormat',tfmt);
stop = datetime('08-Feb-2019 09:26:06:049','InputFormat',tfmt);
x=duration([0 0 stop-start stop-start])
x.Format='s';
plot(x,y)
plot(x,y)

Categories

Find more on Colormaps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!