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

1 vue (au cours des 30 derniers jours)
nas illmatic
nas illmatic le 20 Mar 2019
Réponse apportée : dpb le 20 Mar 2019
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')

Réponses (1)

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

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by