Use logic to determine if array contains a specific date
조회 수: 5 (최근 30일)
이전 댓글 표시
I have an array where one column contains dates in the DD-MM-YYYY format. I am trying to use if statements to do certain things based on what the MM is of a given row. So far I have tried using strcmp( ) and contains( ), but I am not sure how to format it.
x = datetime(2021,12,13);
contains(x,'Dec');
strcmp(x,'Dec');
What is the correct way to format this so that matlab can identify the month component of the date in the array?
댓글 수: 1
채택된 답변
Star Strider
2021년 12월 1일
x = datetime(2021,12,13);
y = datetime(2021,11,13);
TFx = month(x) == 12
TFy = month(y) == 12
.
댓글 수: 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!