Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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')

Respuestas (1)

dpb
dpb el 20 de Mzo. de 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)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by