Matlab does plot datetime data (only hours) on wrong day
Mostra commenti meno recenti
Hello,
I have data from two sensors that I want to plot in the same window to compare differences in my X value.
I have them both stored in tables and use the datetime "HH:mm:ss.SS" format.
For example:
sensor1.Time = ['12:41:50.00'; '12:41:51.00'; ...]
sensor1.x = [0.01; 0.02; 0.02; ...]
and
sensor2.Time = ['12:42:05.46'; '12:42:05.49'; ...]
sensor2.x = [0.01; 0.02; 0.01; ...]
When I plot the data using
plot(sensor1.Time, sensor1.x) it plots the data in a window and adds todays date.

However, when I plot the other table it adds a random date (here: 15.07.2022).

If I plot both using hold on; the data then looks like this which is not very helpful:

How can I fix this date error and have the data aligned on one day?
Best Regards,
Renan
Risposta accettata
Più risposte (2)
the cyclist
il 17 Lug 2022
0 voti
The most fundamental fix to your issue is to explicitly use the modern datetime format for your times. Then, downstream functions that use them as inputs can be manipulated to control the display output.
Also, rather than "MATLAB randomly does something for some reason", one can generally find the exact behavior in the documentation for each function.
Renan Deuter
il 17 Lug 2022
0 voti
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



