Home > matlab > @dynDates > sort.m

sort

PURPOSE ^

sort method for dynDates class.

SYNOPSIS ^

function dd = sort(dd)

DESCRIPTION ^

 sort method for dynDates class.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dd = sort(dd)
0002 % sort method for dynDates class.
0003 
0004 %@info:
0005 %! @deftypefn {Function File} {@var{a} =} sort (@var{a})
0006 %! @anchor{dynDates/sort}
0007 %! @sp 1
0008 %! Sort method for the Dynare dates class.
0009 %! @sp 2
0010 %! @strong{Inputs}
0011 %! @sp 1
0012 %! @table @ @var
0013 %! @item a
0014 %! Object instantiated by @ref{dynDates}.
0015 %! @end table
0016 %! @sp 2
0017 %! @strong{Outputs}
0018 %! @sp 1
0019 %! @table @ @var
0020 %! @item a
0021 %! Object instantiated by @ref{dynDates}, with dates sorted by increasing order.
0022 %! @end table
0023 %! @sp 2
0024 %! @strong{This function is called by:}
0025 %! @sp 2
0026 %! @strong{This function calls:}
0027 %!
0028 %! @end deftypefn
0029 %@eod:
0030 
0031 % Copyright (C) 2011 Dynare Team
0032 %
0033 % This file is part of Dynare.
0034 %
0035 % Dynare is free software: you can redistribute it and/or modify
0036 % it under the terms of the GNU General Public License as published by
0037 % the Free Software Foundation, either version 3 of the License, or
0038 % (at your option) any later version.
0039 %
0040 % Dynare is distributed in the hope that it will be useful,
0041 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0042 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0043 % GNU General Public License for more details.
0044 %
0045 % You should have received a copy of the GNU General Public License
0046 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0047 
0048 % AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
0049 
0050 if ~isa(dd,'dynDates')
0051     error(['dynDates::sort: Input argument ' inputname(dd) ' has to be a dynDates object.'])
0052 end
0053 
0054 if dd.ndat==1
0055     return
0056 end
0057 
0058 dd.time = sortrows(dd.time,[1,2]);
0059 
0060 %@test:1
0061 %$ addpath ../matlab
0062 %$
0063 %$ % Define some dates
0064 %$ B1 = '1953Q4';
0065 %$ B2 = '1950Q2';
0066 %$ B3 = '1950Q1';
0067 %$ B4 = '1945Q3';
0068 %$
0069 %$ % Define expected results.
0070 %$ e.time = [1945 3; 1950 1; 1950 2; 1953 4];
0071 %$ e.freq = 4;
0072 %$ e.ndat = 4;
0073 %$
0074 %$ % Call the tested routine.
0075 %$ d = dynDates(B1,B2,B3,B4);
0076 %$ d = sort(d);
0077 %$
0078 %$ % Check the results.
0079 %$ t(1) = dyn_assert(d.time,e.time);
0080 %$ t(2) = dyn_assert(d.freq,e.freq);
0081 %$ t(3) = dyn_assert(d.ndat,e.ndat);
0082 %$ T = all(t);
0083 %@eof:1

Generated on Fri 18-May-2012 02:41:00 by m2html © 2005