1function ida = get_aux_variable_id(var) 2 3% Returns the index of an auxiliary variable in M_.aux_vars 4% 5% INPUTS 6% - var [string, integer] Variable name or index in M_.endo_names. 7% 8% OUTPUTS 9% - ida [integer] Corresponding index in M_.aux_vars. 10 11% Copyright (C) 2018-2019 Dynare Team 12% 13% This file is part of Dynare. 14% 15% Dynare is free software: you can redistribute it and/or modify 16% it under the terms of the GNU General Public License as published by 17% the Free Software Foundation, either version 3 of the License, or 18% (at your option) any later version. 19% 20% Dynare is distributed in the hope that it will be useful, 21% but WITHOUT ANY WARRANTY; without even the implied warranty of 22% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23% GNU General Public License for more details. 24% 25% You should have received a copy of the GNU General Public License 26% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 27 28global M_ 29 30if isempty(var) 31 ida = 0; 32 return 33end 34 35if ischar(var) 36 id = find(strcmp(var, M_.endo_names)); 37 if isempty(id) 38 ida = 0; 39 return 40 else 41 var = id; 42 end 43else 44 if ~isint(var) || var>M_.endo_nbr || var<1 45 error('Input must be the name of an endogenous variable or an integer between 1 and %s!', num2str(M_.endo_nbr)) 46 end 47end 48 49if var<=M_.orig_endo_nbr 50 % var is not an auxiliary variable. 51 ida = 0; 52else 53 ida = find([M_.aux_vars.endo_index]==var); 54end