Trying to compare datetimes in array to a separate predetermined datetime via function/for loop/if statement
이전 댓글 표시
Hi all,
I am trying to write a function that removes all rows of data after associated with a certain datetime. The idea was for a loop to go through each row of my datetime column and compare that datetime to 2024-07-06. If greater (after this date) the row gets deleted via my if statement. This is the code I wrote:
function [output] = remove_after_07(file_name)
new = file_name ;
for index = 1:length(file_name.date_only)
if index > 2024-07-06
index = []
end
end
output = new ;
endThis is the error I get:
‘Comparison is not defined between datetime and double arrays.’
How can I make it compare the actual dates listed in the column instead of the array?
Thank you!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!