フィルターのクリア

Applying within range function

2 ビュー (過去 30 日間)
Adnan Jayyousi
Adnan Jayyousi 2022 年 6 月 23 日
回答済み: Steven Lord 2022 年 6 月 23 日
Hello everyone,
I am trying to check if ceratin days are withing a specific range, using the withinrange function.
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)'
DateNtime = 8760×1 datetime array
01-Jan-2021 00:00:00 01-Jan-2021 01:00:00 01-Jan-2021 02:00:00 01-Jan-2021 03:00:00 01-Jan-2021 04:00:00 01-Jan-2021 05:00:00 01-Jan-2021 06:00:00 01-Jan-2021 07:00:00 01-Jan-2021 08:00:00 01-Jan-2021 09:00:00 01-Jan-2021 10:00:00 01-Jan-2021 11:00:00 01-Jan-2021 12:00:00 01-Jan-2021 13:00:00 01-Jan-2021 14:00:00 01-Jan-2021 15:00:00 01-Jan-2021 16:00:00 01-Jan-2021 17:00:00 01-Jan-2021 18:00:00 01-Jan-2021 19:00:00 01-Jan-2021 20:00:00 01-Jan-2021 21:00:00 01-Jan-2021 22:00:00 01-Jan-2021 23:00:00 02-Jan-2021 00:00:00 02-Jan-2021 01:00:00 02-Jan-2021 02:00:00 02-Jan-2021 03:00:00 02-Jan-2021 04:00:00 02-Jan-2021 05:00:00
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);
Check for incorrect argument data type or missing argument in call to function 'withinrange'.
-----
In the "tf" array i am getting argument error. What causes the error ?
Thanks

採用された回答

Steven Lord
Steven Lord 2022 年 6 月 23 日
The withinrange function requires its first input to be a timetable, not a datetime array. You probably want isbetween instead.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by