Generalized isconst routine.
parent
c4ddd986ac
commit
fdf6821d0b
|
@ -1,16 +1,14 @@
|
||||||
function aa = isconst(y)
|
function A = isconst(B)
|
||||||
% Returns 1 if vector y is constant, 0 otherwise.
|
|
||||||
|
% Returns an array of logicals, i-th element is `true` if column i of B is constant, `false` otherwise.
|
||||||
%
|
%
|
||||||
% INPUTS:
|
% INPUTS:
|
||||||
% yy [double] n*1 vector.
|
% - B [double] n×m matrix.
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% aa [integer] scalar equal to 1 or 0.
|
% - A [logical] 1×m vector.
|
||||||
%
|
|
||||||
% SPECIAL REQUIREMENTS
|
|
||||||
% none
|
|
||||||
|
|
||||||
% Copyright (C) 2008-2017 Dynare Team
|
% Copyright © 2008-2019 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -26,7 +24,11 @@ function aa = isconst(y)
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>
|
||||||
aa = 0;
|
|
||||||
if all(abs(y(2:end)-y(1:end-1))<1e-10)
|
A = false(1, size(B, 2));
|
||||||
aa = 1;
|
|
||||||
|
for i = 1:size(B, 2)
|
||||||
|
if all(abs(B(2:end,i)-B(1:end-1,i))<1e-12)
|
||||||
|
A(i) = true;
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue