new function

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2528 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2009-03-26 16:33:24 +00:00
parent bab59b7972
commit f7e2d17635
1 changed files with 36 additions and 0 deletions

36
matlab/varlist_indices.m Normal file
View File

@ -0,0 +1,36 @@
function [i_var,nvar] = varlist_indices(varlist)
% function [i_var,nvar] = varlist_indices(varlist)
% returns the indices of a list of endogenous variables
%
% INPUT
% varlist: (character area) list of variables
%
% OUTPUT
% i_var: variable indices in M_.endo_names
% nvar: number of variables in varlist
%
% SPECIAL REQUIREMENTS
% none
%
% part of DYNARE, copyright Dynare Team (2004-2008)
% Gnu Public License.
global M_
endo_nbr = M_.endo_nbr;
if isempty(varlist)
i_var = (1:endo_nbr)';
nvar = endo_nbr;
else
i_var = [];
for i=1:size(varlist,1)
tmp = strmatch(varlist(i,:),M_.endo_names,'exact');
if isempty(tmp)
error([tmp ' isn''t an endogenous variable'])
end
i_var = [i_var; tmp];
end
nvar = length(i_var);
end