The withinrange function requires its first input to be a timetable, not a datetime array. You probably want isbetween instead.
Applying within range function
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!