Combine year and day into single date vector to plot against measurements

1 view (last 30 days)
I have a data set that looks like:
1991 46.000000 -5.08
1991 46.006944 -5.08
1991 46.013889 -5.09
1991 46.020833 -5.09
1991 46.027778 -5.09
1991 46.034722 -5.09
In the format of: year, days since Jan 1 of that year, and a measurement. The whole data set spans several years.
How can I combine both the year and number of days into a date string (or serial date number) that I can continuously plot against the measurements?
Thanks for any help.
  1 Comment
the cyclist
the cyclist on 6 Oct 2019
How are those data stored now? Are they just in a numeric array?
Can you upload the data here (using the paper clip icon), so that we don't have to recreate it?
Are you ok with the output being in a datetime object? That is arguably the best way to store dates in recent versions of MATLAB.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 2019
x = datetime(Data(:,1),1,1) + days(Data(:,2));
plot(x, Data(:,3))

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!