How to convert a timestamp to be able to plot with the times listed?

1 visualización (últimos 30 días)
In my provided data, I have the timestamp of each recorded piece as "2/7/2023 1:12:00 PM" and it takes data every minute. I have the code set up so that I may choose how many points I would like to include in the plot but it will not include the timestamp. I have tried the timestamp function and I don't know what else to try. If you do, please let me know!

Respuestas (1)

Cris LaPierre
Cris LaPierre el 8 de Mayo de 2023
Convert your timestamps to datetimes and then just plot with your datetimes as your x values.
T = ["2/7/2023 1:12:00 PM","2/7/2023 1:13:00 PM","2/7/2023 1:14:00 PM"];
x = datetime(T,'InputFormat','M/d/yyyy h:mm:ss a')
x = 1×3 datetime array
07-Feb-2023 13:12:00 07-Feb-2023 13:13:00 07-Feb-2023 13:14:00
y = [1 2 4];
plot(x,y)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by