Applying within range function
2 views (last 30 days)
Show older comments
Adnan Jayyousi
on 23 Jun 2022
Answered: Steven Lord
on 23 Jun 2022
Hello everyone,
The code is :
%% Define date&time arrays :
t1 = datetime(2021,1,1,0,0,0);
t2 = datetime(2021,12,31,23,0,0);
DateNtime = (t1:hours(1):t2)'
Holidays = datetime({'2021-03-27';'2021-03-28';'2021-04-02';'2021-04-03';
'2021-04-14';'2021-04-15';'2021-5-16';'2021-05-17';'2021-09-06';'2021-09-07';'2021-09-15';'2021-09-16';'2021-09-20';'2021-09-27'});
rangeOfTimes = timerange(t1,t2);
tf = withinrange(Holidays(1,1), rangeOfTimes);
-----
In the "tf" array i am getting argument error. What causes the error ?
Thanks
0 Comments
Accepted Answer
Steven Lord
on 23 Jun 2022
The withinrange function requires its first input to be a timetable, not a datetime array. You probably want isbetween instead.
0 Comments
More Answers (0)
See Also
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!