Home > matlab > isconst.m

isconst

PURPOSE ^

Returns 1 if vector y is constant, 0 otherwise.

SYNOPSIS ^

function aa = isconst(y)

DESCRIPTION ^

 Returns 1 if vector y is constant, 0 otherwise.
  
 INPUTS:
   yy        [double]    n*1 vector.

 OUTPUTS
   aa        [integer]   scalar equal to 1 or 0.

 SPECIAL REQUIREMENTS
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function aa = isconst(y)
0002 % Returns 1 if vector y is constant, 0 otherwise.
0003 %
0004 % INPUTS:
0005 %   yy        [double]    n*1 vector.
0006 %
0007 % OUTPUTS
0008 %   aa        [integer]   scalar equal to 1 or 0.
0009 %
0010 % SPECIAL REQUIREMENTS
0011 %   none
0012 
0013 % Copyright (C) 2008-2009 Dynare Team
0014 %
0015 % This file is part of Dynare.
0016 %
0017 % Dynare is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % Dynare is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU General Public License
0028 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>
0029 aa = 0;
0030 if all(abs(y(2:end)-y(1:end-1))<1e-10)
0031     aa = 1;
0032 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005