This is a static copy of a profile report

Home

datenum (9 calls, 0.020 sec)
Generated 14-Nov-2016 07:47:21 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/timefun/datenum.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
datestrfunction3
imagesci/private/writepngfunction3
datevec>getformatsubfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
92
n = datenummx(datevec(arg1));
30.020 s100.0%
112
end
30 s0%
111
n = dtstr2dtnummx(arg1,matlab....
30 s0%
110
else
30 s0%
108
if isempty(arg2)
30 s0%
All other lines  0 s0%
Totals  0.020 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
datevecfunction30.020 s100.0%
cnv2icudffunction30 s0%
cellstrfunction30 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0.020 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function179
Non-code lines (comments, blank lines)77
Code lines (lines that can run)102
Code lines that did run24
Code lines that did not run78
Coverage (did run/can run)23.53 %
Function listing
time 
calls 
 line
   1 
function n = datenum(arg1,arg2,arg3,h,min,s)
   2 
%DATENUM Serial date number.
   3 
%	N = DATENUM(V) converts one or more date vectors V into serial date 
   4 
%	numbers N. Input V can be an M-by-6 or M-by-3 matrix containing M full 
   5 
%	or partial date vectors respectively.  DATENUM returns a column vector
   6 
%	of M date numbers.
   7 
%
   8 
%	A date vector contains six elements, specifying year, month, day, hour, 
   9 
%	minute, and second. A partial date vector has three elements, specifying 
  10 
%	year, month, and day.  Each element of V must be a positive double 
  11 
%	precision number.  A serial date number of 1 corresponds to Jan-1-0000.  
  12 
%	The year 0000 is merely a reference point and is not intended to be 
  13 
%	interpreted as a real year.
  14 
%
  15 
%	N = DATENUM(S,F) converts one or more date strings S to serial date 
  16 
%	numbers N using format string F. S can be a character array where each
  17 
%	row corresponds to one date string, or one dimensional cell array of 
  18 
%	strings.  DATENUM returns a column vector of M date numbers, where M is 
  19 
%	the number of strings in S. 
  20 
%
  21 
%	All of the date strings in S must have the same format F, which must be
  22 
%	composed of date format symbols according to Table 2 in DATESTR help.
  23 
%
  24 
%	Certain formats may not contain enough information to compute a date
  25 
%	number.  In those cases, hours, minutes, and seconds default to 0, days
  26 
%	default to 1, months default to January, and years default to the
  27 
%	current year. Date strings with two character years are interpreted to
  28 
%	be within the 100 years centered around the current year.
  29 
%
  30 
%	N = DATENUM(S,F,P) or N = DATENUM(S,P,F) uses the specified format F
  31 
%	and the pivot year P to determine the date number N, given the date
  32 
%	string S.  The pivot year is the starting year of the 100-year range in 
  33 
%	which a two-character year resides.  The default pivot year is the 
  34 
%	current year minus 50 years.
  35 
%
  36 
%	N = DATENUM(Y,MO,D) and N = DATENUM([Y,MO,D]) return the serial date
  37 
%	numbers for corresponding elements of the Y,MO,D (year,month,day)
  38 
%	arrays. Y, MO, and D must be arrays of the same size (or any can be a
  39 
%	scalar).
  40 
%
  41 
%	N = DATENUM(Y,MO,D,H,MI,S) and N = DATENUM([Y,MO,D,H,MI,S]) return the
  42 
%	serial date numbers for corresponding elements of the Y,MO,D,H,MI,S
  43 
%	(year,month,day,hour,minute,second) arrays.  The six arguments must be
  44 
%	arrays of the same size (or any can be a scalar).
  45 
%
  46 
%	N = DATENUM(S) converts the string or date vector (as defined by 
  47 
%	DATEVEC) S into a serial date number.  If S is a string, it must be in 
  48 
%	one of the date formats 0,1,2,6,13,14,15,16,23 as defined by DATESTR.
  49 
%	This calling syntax is provided for backward compatibility, and is
  50 
%	significantly slower than the syntax which specifies the format string.
  51 
%	If the format is known, the N = DATENUM(S,F) syntax should be used.
  52 
%
  53 
%	N = DATENUM(S,P) converts the date string S, using pivot year P. If the 
  54 
%	format is known, the N = DATENUM(S,F,P) or N = DATENUM(S,P,F) syntax 
  55 
%	should be used.
  56 
%
  57 
%	Note:  The vectorized calling syntax can offer significant performance
  58 
%	improvement for large arrays.
  59 
%
  60 
%	Examples:
  61 
%		n = datenum('19-May-2000') returns n = 730625. 
  62 
%		n = datenum(2001,12,19) returns n = 731204. 
  63 
%		n = datenum(2001,12,19,18,0,0) returns n = 731204.75. 
  64 
%		n = datenum('19.05.2000','dd.mm.yyyy') returns n = 730625.
  65 
%
  66 
%	See also NOW, DATESTR, DATEVEC, DATETICK.
  67 

  68 
%   Copyright 1984-2011 The MathWorks, Inc.
  69 

      9 
  70 
narginchk(1, 6); 
  71 

  72 
% parse input arguments
      9 
  73 
isdatestr = ~isnumeric(arg1); 
      9 
  74 
isdateformat = false; 
      9 
  75 
if nargin == 2 
      3 
  76 
    isdateformat = ischar(arg2); 
      6 
  77 
elseif nargin == 3 
  78 
    isdateformat = [ischar(arg2), ischar(arg3)];
  79 
end
  80 

      9 
  81 
if isdatestr && isempty(arg1) 
  82 
    n = zeros(0,1);
  83 
	warning(message('MATLAB:datenum:EmptyDate'));
  84 
    return;
  85 
end
  86 

  87 
% try to convert date string or date vector to a date number
      9 
  88 
try 
      9 
  89 
    switch nargin 
      9 
  90 
        case 1  
      6 
  91 
            if isdatestr 
  0.02 
      3 
  92 
                n = datenummx(datevec(arg1)); 
      3 
  93 
            elseif ((size(arg1,2)==3) || (size(arg1,2)==6)) && ... 
  94 
                    any(abs(arg1(:,1) - 2000) < 10000)
      3 
  95 
                n = datenummx(arg1); 
  96 
            else
  97 
                n = arg1;
  98 
            end
      3 
  99 
        case 2 
      3 
 100 
            if isdateformat 
      3 
 101 
                if ischar(arg1) 
      3 
 102 
					arg1 = cellstr(arg1); 
      3 
 103 
                end 
      3 
 104 
                if ~iscellstr(arg1) 
 105 
                    %At this point we should have a cell array.  Otherwise error.
 106 
                    error(message('MATLAB:datenum:NotAStringArray'));
 107 
                end
      3 
 108 
                if isempty(arg2) 
 109 
                    n = datenummx(datevec(arg1));
      3 
 110 
                else 
      3 
 111 
                    n = dtstr2dtnummx(arg1,matlab.internal.datetime.cnv2icudf(arg2));              
      3 
 112 
                end 
 113 
            else
 114 
                n = datenummx(datevec(arg1,arg2));
 115 
            end
 116 
        case 3
 117 
			if any(isdateformat)
 118 
				if isdateformat(1) 
 119 
					format = arg2;
 120 
					pivot = arg3;
 121 
				elseif isdateformat(2)
 122 
					format = arg3;
 123 
					pivot = arg2;
 124 
				end
 125 
				if ischar(arg1)
 126 
					arg1 = cellstr(arg1);
 127 
				end
 128 
                if ~iscellstr(arg1)
 129 
                    %At this point we should have a cell array.  Otherwise error.
 130 
                    error(message('MATLAB:datenum:NotAStringArray'));
 131 
                end
 132 
				icu_dtformat = matlab.internal.datetime.cnv2icudf(format);
 133 
				showyr =  strfind(icu_dtformat,'y'); 
 134 
                if ~isempty(showyr)
 135 
                    wrtYr =  numel(showyr);
 136 
                    checkYr = diff(showyr);
 137 
                    if any(checkYr~=1)
 138 
                        error(message('MATLAB:datenum:YearFormat'));
 139 
                    end
 140 
                    switch wrtYr
 141 
                        case 4
 142 
                            icu_dtformat = strrep(icu_dtformat,'yyyy','yy');
 143 
                        case 3
 144 
                            icu_dtformat = strrep(icu_dtformat,'yyy','yy');
 145 
                    end
 146 
                end
 147 
                if (isempty(format))
 148 
                    n = datenummx(datevec(arg1,pivot));
 149 
                else
 150 
                    if (isempty(pivot))
 151 
                        n = dtstr2dtnummx(arg1,icu_dtformat);
 152 
                    else
 153 
                        n = dtstr2dtnummx(arg1,icu_dtformat,pivot);
 154 
                    end
 155 
                end
 156 
            else
 157 
                verifySizes(arg1,arg2,arg3);
 158 
                n = datenummx(arg1,arg2,arg3);
 159 
			end
 160 
        case 6
 161 
            verifySizes(arg1,arg2,arg3,h,min,s);
 162 
            n = datenummx(arg1,arg2,arg3,h,min,s);
 163 
        otherwise
 164 
            error(message('MATLAB:datenum:Nargin'));
 165 
    end
 166 
catch exception   
 167 
    if (nargin == 1 && ~isdatestr)
 168 
        identifier = 'MATLAB:datenum:ConvertDateNumber';
 169 
    elseif (nargin == 1 && isdatestr) || (isdatestr && any(isdateformat))
 170 
        identifier = 'MATLAB:datenum:ConvertDateString';
 171 
    elseif (nargin > 1) && ~isdatestr && ~any(isdateformat)
 172 
        identifier = 'MATLAB:datenum:ConvertDateVector';
 173 
    else
 174 
        identifier = exception.identifier;
 175 
    end
 176 
    newExc = MException( identifier,'%s',getString(message('MATLAB:datenum:Failed')));
 177 
    newExc = newExc.addCause(exception);
 178 
    throw(newExc);
 179 
end

Other subfunctions in this file are not included in this listing.