Code covered by the BSD License  

Highlights from
dlim

dlim

by

 

set date limits like they're x limits.

dlim(varargin)
function [] = dlim(varargin)
% DLIM sets DATE limits when the horizontal axis references date numbers.  
% This function is similar to xlim, but uses dates as inputs. 
% 
% SYNTAX: 
% dlim([dmin dmax]) sets the date limits for datenumbers dmin and dmax.
% dlim(dmin,dmax) sets the date limits for datenumbers or datestrings dmin and dmax.
% 
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
% EXAMPLES: 
% 
% d = datenum('jan 1, 1990'):1:datenum('dec 31,2009'); 
% y = 2*sin(t2/90)+rand(size(d)); 
% figure
% plot(d,y)
% dlim('may 5, 1997','june 20, 2004') % <-- The dlim Function
% datetick('x','mmm-yy','keeplimits')
% 
% In the example above, the dlim command could similarly be given by
% dlim([729515 732118]) or dlim(729515,732118).
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
% 
% Written by Chad A. Greene, datestr(735618). 
%
% See also XLIM, DATETICK, YLIM.

if nargin == 1 
    dlim = varargin{1}; 
    
end

if nargin == 2
    if ischar(varargin{1})
        dlim(1) = datenum(varargin{1});     
    end
    if ischar(varargin{2})
        dlim(2) = datenum(varargin{2});     
    end    
end

xlim([dlim(1) dlim(2)]); 

    
end

Contact us