sec2hms.m

来自「航天工程工具箱」· M 代码 · 共 20 行

M
20
字号
function [h,m,s]=sec2hms(x)
%SEC2HMS  Convert seconds into hms format.
%   [H,M,S] = SEC2HMS(SEC) converts value SEC in unit seconds
%   into hours H, minutes M and seconds S.
%
%   HMS = SEC2HMS(SEC) converts value SEC in unit seconds
%   to a vector corresponding to the values [H M S] above.
%
%   See also HMS2SEC, DMS2DEG, DEG2DMS, NUM2MASS.

% Copyright (c) 2002-02-09, B. Rasmus Anthin.

h=floor(x/3600);
rest=x-3600*h;
m=floor(rest/60);
s=rest-60*m;
if nargout<3
   h(2)=m;
   h(3)=s;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?