How to plot date and time on one axis?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Phil
am 1 Apr. 2015
Bearbeitet: Campion Loong
am 24 Apr. 2015
Dear everyone,
I'm trying to plot data I read from a sensor that saves these in a .txt file (example data and the function are attached). The column structure is as follows: Date, time, temperature and relative humidity. However, I run into problems when the day changes e.g. from 19/03/15 to 20/03/15. I would like to plot 20/03/15 exactly at 00:00. Maybe it is a problem with autoscaling? I tried plotting the data twice on the same x-axis with different positions, but this does not solve the problem.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148581/image.png)
The problem that then also arises is during zooming as the y-axis scales differently.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148582/image.png)
I would appreciate any help with this!
Regards
Philipp
0 Kommentare
Akzeptierte Antwort
Campion Loong
am 24 Apr. 2015
Bearbeitet: Campion Loong
am 24 Apr. 2015
Hi Philipp,
It's been some time since your question. Hopefully this can still be of some help.
If you have access to MATLAB 2014b or later, you can actually take advantage of the datetime datatype to simplify much of your text parsing and plotting.
I have attached a sample workflow that reads your data as a MATLAB table and plots the temperature with time. The code is much simpler (4 lines without comments). The resulting plot will update itself as you pan or zoom around. You can customize and annotate your plot further to suit your specific needs.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!