From 618f72bc9120fce480bce03188c93b9fe3eaad32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 25 Nov 2010 17:26:35 +0100 Subject: [PATCH] resid displays the name of the equations if they are specified in equations tags. --- matlab/resid.m | 30 ++++++++++++++++++++++++++++-- matlab/select_from_table.m | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 matlab/select_from_table.m diff --git a/matlab/resid.m b/matlab/resid.m index d0611ec36..c3f06ee09 100644 --- a/matlab/resid.m +++ b/matlab/resid.m @@ -31,6 +31,20 @@ function z = resid(junk) global M_ options_ oo_ +tagname = 'name'; +if nargin && ischar(junk) + tagname = junk; +end + + +tags = M_.equations_tags; +istag = 0; +if length(tags) + istag = 1; +end + + + steady_state_old = oo_.steady_state; % If using a steady state file, initialize oo_.steady_state with that file @@ -80,19 +94,31 @@ else oo_.exo_det_steady_state], M_.params); end + % Display the non-zero residuals if no return value if nargout == 0 for i = 1:4 disp(' ') end - + disp('Residuals of the static equations:') + disp(' ') for i=1:M_.orig_endo_nbr if abs(z(i)) < options_.dynatol/100 tmp = 0; else tmp = z(i); end - disp(['Residual for equation number ' int2str(i) ' is equal to ' num2str(tmp)]) + if istag + tg = tags(cell2mat(tags(:,1)) == i,2:3); % all tags for equation i + ind = strmatch( tagname, cellstr( tg(:,1) ) ); + end + if length(ind) == 0 || ~istag + disp(['Equation number ' int2str(i) ' : ' num2str(tmp)]) + else + t1 = tg( ind , 2 ); + s = cell2mat(t1); + disp( ['Equation number ', int2str(i) ,' : ', num2str(tmp) ,' : ' s]) + end end for i = 1:2 disp(' ') diff --git a/matlab/select_from_table.m b/matlab/select_from_table.m new file mode 100644 index 000000000..346ab7141 --- /dev/null +++ b/matlab/select_from_table.m @@ -0,0 +1,24 @@ +function [indices] = select_from_table(table,key,value) +% Copyright (C) 2010 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + candidates = table(strmatch(key,table(:,2),'exact'),:); + if nargin == 2 + indices = cell2mat( candidates(:,1) ); + return; + end + indices = candidates(strmatch(value, candidates(:,3), 'exact'),1); + indices = cell2mat(indices);