plot specific time points of everyday in an automated data

3 views (last 30 days)
Hi there
I am working with autmated weight data recorded every 15 minutes ove 14 months. I really need help to plot specific time points for every single day for example I need to plot weight data for every day between 4-6am over the 14 month.
Your help will be highly appreciated
  1 Comment
dpb
dpb on 9 Jun 2021
Use a timetable and timerange to segment the data over periods of interest...

Sign in to comment.

Answers (1)

Duncan Po
Duncan Po on 9 Jun 2021
See this example of checking the hour component of a datetime, and then using logical indexing to extract a time range:
dt = datetime(2021,1,1):minutes(15):datetime(2021,1,4); % construct a datetime every 15 minutes for 3 days
h = hour(dt);
dt1 = dt(h >= 4 & h < 6); % extract only between 4am and 6am
dt1(1:5)
ans =
1×5 datetime array
01-Jan-2021 04:00:00 01-Jan-2021 04:15:00 01-Jan-2021 04:30:00 01-Jan-2021 04:45:00 01-Jan-2021 05:00:00
  1 Comment
dpb
dpb on 9 Jun 2021
Edited: dpb on 9 Jun 2021
Indeed, timerange() does NOT have sufficient intelligence built into it to be able to isolate a time-of-day section; it is a brute-force-only club, it seems.
I think this is a big oversight in functionality; one should NOT have to build secondary grouping/selection variables manually for such tasks.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!