Select subset of dates

8 views (last 30 days)
alpedhuez
alpedhuez on 23 May 2020
Commented: Ameer Hamza on 23 May 2020
I have data
T.date
T.temperature
T.date runs from January 1, 2019 to December 31, 2019.
I now want to subset the date from January 1, 2019 to June 31, 2019 and draw the plot of T.temperature on that subset of date. How should one write the code?

Accepted Answer

Ameer Hamza
Ameer Hamza on 23 May 2020
Something like this
start_date = datetime(2019, 1, 1);
end_date = datetime(2019, 6, 30);
idx = (start_date < T.date) & (T.date < end_date);
T_new = T(idx, :)
  2 Comments
alpedhuez
alpedhuez on 23 May 2020
Thank you.
Ameer Hamza
Ameer Hamza on 23 May 2020
I am glad to be of help!

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!