%% For the given time vector (fractional hours) and requested time increment 
%% pwtimelabel.m determines the output vectors required for the 
%% xtick and xticklabel commands.
%% 
%% Author: Phillip A. Webb
%% Last updated: October 18 2005
%%

function [xtickv, xticklabelv] = pwtimelabel(timv, dt)

% timv = time vector (fractional hours)
% dt = time step required (fractional hours)
% xtickv = required xtick vector (fractional hours)
% xticklabelv = required xticklabel vector (string array)

tims = dt * ceil(min(timv) / dt);           %start time
timf = dt * floor(max(timv) / dt);          %finish time
xtickv = tims:dt:timf;                      

xticklabelv = [];
for i = 1 : length(xtickv)
   [hrmat,mnmat]=timfh2hms(xtickv(i)); 
   xti=[num2str(hrmat,'%02.0f') num2str(mnmat,'%02.0f')];
   xticklabelv = [xticklabelv; xti];
end
