I have a matrix with one column in serial datenumber format, how do I select data from a certain time period?
Show older comments
I have a large dataset where the first column is filled with serial datenumbers. I want to use these to select the rows of data for time periods of interest. For example, the first row in this data set (2) corresponds to the 29th May 2019 and runs til the end of July. I want to extract, for example, data from June only. How do I do this? I know I could convert the column to datetime and then select the rows of interest from there, but is there a simpler way?

4 Comments
"I know I could convert the column to datetime and then select the rows of interest from there, but is there a simpler way? "
What's difficult about that? If you're using >1 line of code to convert that column to datetime, show us what you're doing.
Note that you can also select rows of interest from the date-number format, too.
Louise Wilson
on 25 Oct 2019
Louise Wilson
on 25 Oct 2019
Adam Danz
on 25 Oct 2019
If there's no need to be able to read the dates, you can just use indexing as Stephen Cobeldick explained in his answer. If you need to read the dates, you can convert them and using indexing from datetime format as well.
Accepted Answer
More 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!