📄 time2sec.m
字号:
function S=time2sec(t)%TIME2SEC Converts the time in seconds.%% S = TIME2SEC(TIME)%% TIME can be a string in the format 'hh:mm:ss'% or a vector of 3 elements [hh mm ss].% Return the number of seconds.%% See also: SEC2TIME TIME CLOCK TIC TOC ETIME%% Claudio 7 June 1995.%%%% Copyright (c) 1995 by Claudio Rivetti and Mark Young% claudio@alice.uoregon.edu, mark@alice.uoregon.edu%if nargin < 1 error('Not enough input arguments.');endif nargin > 1 error('Too many input arguments.');endif isstr(t) if length(t) ~=8 | t(3)~=':' | t(6)~=':' error('Input string must be in the format hh:mm:ss'); endelse if length(t) ~= 3 error('Input vector must contein 3 elements [hh, mm, ss]'); endendif isstr(t) h=str2num(t(1:2)); m=str2num(t(4:5)); s=str2num(t(7:8));else h=t(1); m=t(2); s=t(3);endS = s + m*60 + h*3600;return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -