Borrar filtros
Borrar filtros

Timestamp - x axis

6 visualizaciones (últimos 30 días)
Lola
Lola el 27 de Nov. de 2022
Respondida: millercommamatt el 28 de Nov. de 2022
Hi. I am trying to plot sensor data in realtime using the animated line function. I want to plot the timestamp when the data is updated against each sensor value on the x axis. I have tried the code below for the x axis:
g=datetime("now");
b=datenum(g);
addpoints(app.h,b,app.count);
drawnow;
The problem is the x axis labels are displaying as number 7.388....×10^5. Please assist

Respuestas (1)

millercommamatt
millercommamatt el 28 de Nov. de 2022
It's because you're turned your datetime type variable into a datenum and plotted that. Datenums are the number of days since January 0, 0000. animatedline is not datetime aware insofar as I'm aware. You're probably going to have to format your own XLabels to use date strings for find a helper function to do the relabeling for you.
Or, use a standard plot instead of animatedline since plot is datetime aware.
A related issue: https://www.mathworks.com/matlabcentral/answers/541319-change-uiaxes-datenum-to-datetime-in-appdesigner-for-animatedline-plot

Categorías

Más información sobre Animation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by