Hello,
I imported two column vectors from a .xlsx file. The first one is called "Date", and contains the date and time of a corresponding measurement, in the format: 'yyyy-mm-dd hh:mm:ss. The second vector contains the corresponding measurment on that timestamp, let's call it 'Height'.
I tried to plot these vectors with the standard 'plot(Date,Height)' function, to see the chance of height over time. Note that the time spans multiple years, and contains thousands of measurements.
But the plot returns a tangeled mess of a graph, where the data points seem to be connected randomly to each other. I am aware of the datetime datatype, and the option to convert timestamps into different formats, without sucess in using them. But how do I get a decently looking graph, with which I can see the chance in height over time?
Thanks in Advance!

댓글 수: 4

Mathieu NOE
Mathieu NOE 2021년 11월 23일
hello
maybe you should share your code along with a sample xlsx file
tx
Peter Perkins
Peter Perkins 2021년 11월 23일
Spaghetti like that usually indicates that the times are not sorted.
datetime plots work well. Import your data using readtimetable (or readtable and then table2timetable in earlier MATLAB versions) and call sortrows.
And, as Mathieu says, show a small sample of what you have.
Tim Richter
Tim Richter 2021년 11월 26일
Sorting the tables helped, thanks!
Bjorn Gustavsson
Bjorn Gustavsson 2021년 11월 26일
For these types of long-term series there often are seasonal (and possibly daily) variations, to enhance those you might consider using plot3 or scatter3 where you have year on the x-axis, day of year on the y-axis and your height along the z-axis (and colour-scale).

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Time Series Events에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2021년 11월 23일

댓글:

2021년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by