Matlab calculates the duration from the start time and the end time
1. According to the function format, enter the start time and end time.
2. Run the program and calculate the duration.
3. Source code.
function y=tool2time_during(start_time,finish_time)
%起始时间--时、分、秒
start_hou=start_time(1);
start_min=start_time(2);
start_sec=start_time(3);
%终止时间--时、分、秒
finish_hou=finish_time(1);
finish_min=finish_time(2);
finish_sec=finish_time(3);
%计算经历时间
time_during=(finish_sec+finish_min*60+finish_hou*3600)-(start_sec+start_min*60+start_hou*3600);
%返回值y
y=time_during;
%输出显示
time_during=[num2str(time_during),' 秒 ']
end