Date/time plot

9 views (last 30 days)
Iacopo
Iacopo on 11 May 2022
Commented: dpb on 11 May 2022
Hi all,
I would like to change the xlabel of my plot from samples to seconds. The plot I make is a recording from an instrument.
I managed to get the start date from the text file header (in datetime format).
Now I would like to display in the x-axis of my plot the date and time in seconds (and then hours, days and date) instead of samples (which is the first column of my text file).
I attached my file for you to see.
Thanks to anyone who will help me.
  1 Comment
dpb
dpb on 11 May 2022
Your first column is in some unit of time; one presumes seconds relative to the date stamp at the header, (at least approximately, we have no idea whether that datestamp actuall represents the trigger time or was when the file was written after the acquisition or sometime before with an undetermined delay before trigger).
Anyways, that aside,
tYourData.SampleTime=theStartDateTimeYouGot+seconds(tYourData.Time);
will give you a datetime variable that is that time vector.
Plotting against it will give you a datetimeRuler x axis which you can format as desired. It will be clumsy; it takes a lot of space to write date labels, but it will do it.

Sign in to comment.

Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!