image thumbnail
from Date/time stamp in a plot by Sverre Holm
Puts "14-SEP-2006 15:50" in the right-hand corner of the current plot

datetext()
%------------------------------------------------------------------------
% Function        : Datetext.m
%
% Description     : Printing date in the upper right-hand corner of a plot  
%
% Language        : Matlab
% Written by      : Sverre Holm, University of Oslo
% Date            : 12. July 1990
%
% Modified 17.09.93 by MM, Vingmed Sound:
% 	h = datetext, where h is a handle to the text.
%	delete(h) will remove the date text. 
%	units of h is forced to 'normalized'.       
% Version no.     : 1.0
%                 : 2.0 FT 11.02.94 Removed two redundant lines
%                       SH 15.09.06 Minor editing to remove M-lint messages
%                       from Matlab Cengtral Check
% 
% Routines called : datetime.m
% Output parameters : h - handle to figure
% Input parameters  : none
%------------------------------------------------------------------------


        function h = datetext()
        datetime;
        h = text(0.68,0.88,datetime,'units','normalized');
        return
        
%------------------------------------------------------------------------
% function datetime=datetime
%
% Description : datetime returns the date and time in the following format:
%               15-MAR-1989 13:09
% Language    : Matlab
% Written by  : Sverre Holm, Informasjonskontroll AS
%               now University of Oslo
%
% Completed   : April 1989
% Routines called   : none
% Output parameters : datetime
% Input parameters  : none
%------------------------------------------------------------------------
function datetime=datetime

%get system time
time=fix(clock);
%
% month
months = ['JAN';'FEB';'MAR';'APR';'MAY';'JUN';'JUL';'AUG';'SEP';'OCT';'NOV';'DEC'];
% 
% special precautions for leading zeroes or spaces
%
if time(3) < 10 
    dayfill=' '; 
else
    dayfill='';
end;
if time(4) < 10 
    hourfill='  ';
else
    hourfill=' ';
end;
if time(5) < 
    10 minfill=':0';  
else
    minfill=':';
end;
%
% day, month, year
datetime=[dayfill,int2str(time(3)),'-',months(time(2),:),'-',int2str(time(1))];
%
% hour and minute
datetime=[datetime,hourfill,int2str(time(4)),minfill,int2str(time(5))];
clear months dayfill hourfill minfill;
 


Contact us at files@mathworks.com