


@info:
! @deftypefn {Function File} {@var{c} =} min (@var{a},@var{b})
! @anchor{@dynDate/gt}
! @sp 1
! Overloads the min function for the Dynare dates class (@ref{dynDate}).
! @sp 2
! @strong{Inputs}
! @sp 1
! @table @ @var
! @item a
! Dynare date object instantiated by @ref{dynDate}.
! @item b
! Dynare date object instantiated by @ref{dynDate}.
! @end table
! @sp 1
! @strong{Outputs}
! @sp 1
! @table @ @var
! @item c
! Dynare date object instantiated by @ref{dynDate}. @var{c} is a copy of @var{a} if @var{a}<=@var{b}, a copy of @var{b} otherwise.
! @end table
! @sp 2
! @strong{This function is called by:}
! @sp 2
! @strong{This function calls:}
!
! @end deftypefn
@eod:

0001 function c = min(a,b) 0002 0003 %@info: 0004 %! @deftypefn {Function File} {@var{c} =} min (@var{a},@var{b}) 0005 %! @anchor{@dynDate/gt} 0006 %! @sp 1 0007 %! Overloads the min function for the Dynare dates class (@ref{dynDate}). 0008 %! @sp 2 0009 %! @strong{Inputs} 0010 %! @sp 1 0011 %! @table @ @var 0012 %! @item a 0013 %! Dynare date object instantiated by @ref{dynDate}. 0014 %! @item b 0015 %! Dynare date object instantiated by @ref{dynDate}. 0016 %! @end table 0017 %! @sp 1 0018 %! @strong{Outputs} 0019 %! @sp 1 0020 %! @table @ @var 0021 %! @item c 0022 %! Dynare date object instantiated by @ref{dynDate}. @var{c} is a copy of @var{a} if @var{a}<=@var{b}, a copy of @var{b} otherwise. 0023 %! @end table 0024 %! @sp 2 0025 %! @strong{This function is called by:} 0026 %! @sp 2 0027 %! @strong{This function calls:} 0028 %! 0029 %! @end deftypefn 0030 %@eod: 0031 0032 % Copyright (C) 2011 Dynare Team 0033 % stephane DOT adjemian AT univ DASH lemans DOT fr 0034 % 0035 % This file is part of Dynare. 0036 % 0037 % Dynare is free software: you can redistribute it and/or modify 0038 % it under the terms of the GNU General Public License as published by 0039 % the Free Software Foundation, either version 3 of the License, or 0040 % (at your option) any later version. 0041 % 0042 % Dynare is distributed in the hope that it will be useful, 0043 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0044 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0045 % GNU General Public License for more details. 0046 % 0047 % You should have received a copy of the GNU General Public License 0048 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0049 0050 verbose = 0; 0051 0052 if nargin~=2 0053 error('dynDate::min: I need exactly two input arguments!') 0054 end 0055 0056 if ~( isa(a,'dynDate') && isa(b,'dynDate')) 0057 error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have to be a dynDate objects!']) 0058 end 0059 0060 if verbose && a.freq~=b.freq 0061 error(['dynDate::min: Input arguments ' inputname(1) 'and ' inputname(2) ' have no common frequencies!']) 0062 end 0063 0064 if a<=b 0065 c = a; 0066 else 0067 c = b; 0068 end 0069 0070 %@test:1 0071 %$ addpath ../matlab 0072 %$ 0073 %$ % Define some dates 0074 %$ date_1 = 1950; 0075 %$ date_2 = 2000; 0076 %$ date_3 = '1950Q2'; 0077 %$ date_4 = '1950Q3'; 0078 %$ date_5 = '1950M1'; 0079 %$ date_6 = '1948M6'; 0080 %$ 0081 %$ % Call the tested routine. 0082 %$ d1 = dynDate(date_1); 0083 %$ d2 = dynDate(date_2); 0084 %$ d3 = dynDate(date_3); 0085 %$ d4 = dynDate(date_4); 0086 %$ d5 = dynDate(date_5); 0087 %$ d6 = dynDate(date_6); 0088 %$ m1 = min(d1,d2); 0089 %$ i1 = (m1==d1); 0090 %$ m2 = min(d3,d4); 0091 %$ i2 = (m2==d3); 0092 %$ m3 = min(d5,d6); 0093 %$ i3 = (m3==d6); 0094 %$ 0095 %$ % Check the results. 0096 %$ t(1) = dyn_assert(i1,1); 0097 %$ t(2) = dyn_assert(i2,1); 0098 %$ t(3) = dyn_assert(i3,1); 0099 %$ T = all(t); 0100 %@eof:1