Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在给定的时间间隔内比较时间字符串“09:12:00”?如 , T = '09:12:00';
if ('03:00:00' < T < '05:00:00') 结束
只需通过datenum将时间字符串转换为日期序列号
if ( datenum('03:00:00') < datenum(T) & datenum(T) < datenum('05:00:00') ) end
我不知道是否存在可以进行 C 风格比较的标准 Matlab 函数,就像这些用户编写的函数所做的那样:lexcmp,strcmpc ...
它不一定漂亮,但你可以使用sort、strcmp和find:
T = '09:12:00'; S = sort({'03:00:00', T, '05:00:00'}); F = find(strcmp(T, S)); if (1 == length(F) && 2 == F(1)) % if T is between given limits... end