创建一组时间序列

clear

clc

close all

% 创建起始时间和结束时间

startDateTime = datetime('2024-01-01 00:00:00', 'Format', 'yyyy-MM-dd HH:mm:ss');

endDateTime = datetime('2024-01-01 23:59:59', 'Format', 'yyyy-MM-dd HH:mm:ss');

% 创建时间点序列,每隔一分钟

timePoints = startDateTime:minutes(1):endDateTime;

timePoints=timePoints';

% 找到特定时间点的行

targetDateTime = datetime('2024-01-01 00:37:00', 'Format', 'yyyy-MM-dd HH:mm:ss');

rowIndex = find(timePoints == targetDateTime)

% 显示结果

disp(timePoints);

你可能感兴趣的:(matlab)