MATLAB: DateTime equal but report not equal datetimdatetime compare Time1=datetime('04:00:00','InputFormat',"HH:mm:ss");Time2=datetime(0,0,0,4,0,0);Time1~=Time2 ans = logical 1 Best Answer They are not the same: Time1=datetime('04:00:00','InputFormat',"HH:mm:ss")Time2=datetime(0,0,0,4,0,0)produces: Time1 = datetime 25-Jul-2020 04:00:00and: Time2 = datetime 30-Nov--0001 04:00:00. Related SolutionsMATLAB: Equal Cell if strcmp(datLab{k}, label{i})orif isequal(datLab{k}, label{i}) MATLAB: Equals numbers returns not equal Are you sure that they are exactly the same?Try format long and then display your values again. I guess that temp is only roughly 0.0207 and not exactly.If that is the reason for your problem, you can try the following:if item ~= round(temp,4) Related QuestionHow to define a time array with equal incrementTwo equal numbers are not equalConvert min, hours to 00:00:00 format
Best Answer