Code covered by the BSD License  

Highlights from
A MATLAB Script for Time and Coordinate Calculations

A MATLAB Script for Time and Coordinate Calculations

by

 

Interactive MATLAB script that can be used to perform time and coordinate calculations.

hrs2hms (hrs)
function [h, m, s, hmsstr] = hrs2hms (hrs)

% convert decimal hours to hours,
% minutes, seconds and equivalent string

% input

%  dd = angle in hours

% output

%  h      = integer hours
%  m      = integer minutes
%  s      = seconds
%  hmsstr = string equivalent of input

% Orbital Mechanics with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if (hrs < 0)
   hrs = hrs + 24;
end

h = abs(hrs);
   
d = fix(h);
   
d1 = (h - d) * 60;
   
m = fix(d1);
   
s = (d1 - m) * 60;
    
hmsstr = sprintf('%+03d%s%02d%s%06.4f%s', d,...
            'h ', m, 'm ', s,'s');

 


Contact us