diff --git a/matlab/get_equation_name_by_number.m b/matlab/get_equation_name_by_number.m new file mode 100644 index 0000000000000000000000000000000000000000..11f98884740ae06c73a7f6f7ce678a9f27db97a0 --- /dev/null +++ b/matlab/get_equation_name_by_number.m @@ -0,0 +1,28 @@ +function eqname = get_equation_name_by_number(eqnumber, M_) +% Returns the name of an equation given its number + +% Copyright © 2022 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 <https://www.gnu.org/licenses/>. + +idx_for_this_eq = find(cell2mat(M_.equations_tags(:,1)) == eqnumber); +eqname = cell2mat(M_.equations_tags(idx_for_this_eq(strmatch('name', M_.equations_tags(idx_for_this_eq, 2), 'exact')), 3)); + +if isempty(eqname) + eqname = ''; +end + +end diff --git a/matlab/model_info.m b/matlab/model_info.m index 8be10ddf45d9417be157d35146fa5629ab35f63a..5744a45f9fd2e41f1f1d14e1caefd303310ec491 100644 --- a/matlab/model_info.m +++ b/matlab/model_info.m @@ -43,23 +43,23 @@ if isfield(M_,block_structre_str) fprintf(strcat(' ===================',char(ones(1,length(M_.fname))*'='),'\n\n')); nb_blocks=length(block_structure.block); fprintf('The model has %d equations and is decomposed in %d blocks as follow:\n',M_.endo_nbr,nb_blocks); - fprintf('===============================================================================================================\n'); - fprintf('| %10s | %10s | %30s | %14s | %31s |\n','Block no','Size','Block Type',' Equation','Dependent variable'); - fprintf('|============|============|================================|================|=================================|\n'); + fprintf('================================================================================================================================\n'); + fprintf('| %10s | %10s | %30s | %31s | %31s |\n','Block no','Size','Block Type','Equation','Dependent variable'); + fprintf('|============|============|================================|=================================|=================================|\n'); for i=1:nb_blocks size_block=length(block_structure.block(i).equation); if(i>1) - fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n'); + fprintf('|------------|------------|--------------------------------|---------------------------------|---------------------------------|\n'); end for j=1:size_block if(j==1) - fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)}); + fprintf('| %10d | %10d | %30s | %-6d %24s | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),get_equation_name_by_number(block_structure.block(i).equation(j), M_),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)}); else - fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)}); + fprintf('| %10s | %10s | %30s | %-6d %24s | %-6d %24s |\n','','','',block_structure.block(i).equation(j),get_equation_name_by_number(block_structure.block(i).equation(j), M_),block_structure.block(i).variable(j),M_.endo_names{block_structure.block(i).variable(j)}); end end end - fprintf('===============================================================================================================\n'); + fprintf('================================================================================================================================\n'); fprintf('\n'); if static_ fprintf('%-30s %s','the variable','is used in the following equations contemporaneously');