Home > matlab > indnv.m

indnv

PURPOSE ^

function a=indnv(x,y)

SYNOPSIS ^

function a=indnv(x,y)

DESCRIPTION ^

 function a=indnv(x,y)
 Finds the elements indices of one vector in an other one

 INPUTS
    x:         column vector
    y:         column vector

 OUTPUTS
    a:         vector of elements position of x in y

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function a=indnv(x,y)
0002 
0003 % function a=indnv(x,y)
0004 % Finds the elements indices of one vector in an other one
0005 %
0006 % INPUTS
0007 %    x:         column vector
0008 %    y:         column vector
0009 %
0010 % OUTPUTS
0011 %    a:         vector of elements position of x in y
0012 %
0013 % SPECIAL REQUIREMENTS
0014 %    none
0015 
0016 % Copyright (C) 2001-2009 Dynare Team
0017 %
0018 % This file is part of Dynare.
0019 %
0020 % Dynare is free software: you can redistribute it and/or modify
0021 % it under the terms of the GNU General Public License as published by
0022 % the Free Software Foundation, either version 3 of the License, or
0023 % (at your option) any later version.
0024 %
0025 % Dynare is distributed in the hope that it will be useful,
0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0028 % GNU General Public License for more details.
0029 %
0030 % You should have received a copy of the GNU General Public License
0031 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0032 
0033 a = zeros(size(x)) ;
0034 
0035 for i = 1:size(x,1)
0036     j = find( x(i) == y );
0037     if isempty(j)
0038         a(i) = NaN;
0039     else
0040         a(i) = j;
0041     end
0042 end
0043 
0044 
0045

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005