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

2 visualizzazioni (ultimi 30 giorni)
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')

Risposte (1)

dpb
dpb il 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)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by