Home > atmlab > math > nearestinvec.m

nearestinvec

PURPOSE ^

[ind,zn] = nearestinvec(z,zi)

SYNOPSIS ^

function [ind,zn] = nearestinvec(z,zi);

DESCRIPTION ^

 [ind,zn] = nearestinvec(z,zi)

          Find the nearest value in a vector z to a given value zi

 FORMAT   [ind,zn] = nearestinvec(z,zi)

 OUT      ind  the index in vector z of closest value to zi
          zn   the closest value in z to zi
 IN       z    the vector
          zi   the value

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

nearestinvec.m

SOURCE CODE ^

0001 % [ind,zn] = nearestinvec(z,zi)
0002 %
0003 %          Find the nearest value in a vector z to a given value zi
0004 %
0005 % FORMAT   [ind,zn] = nearestinvec(z,zi)
0006 %
0007 % OUT      ind  the index in vector z of closest value to zi
0008 %          zn   the closest value in z to zi
0009 % IN       z    the vector
0010 %          zi   the value
0011 
0012 % 2003-02-10   Created by Carlos Jimenez
0013 
0014 function [ind,zn] = nearestinvec(z,zi);
0015 
0016 [ aux, ind ] = min( abs( z -zi ) );
0017 zn           = z( ind );
0018 
0019 return
0020 
0021 
0022 
0023 
0024

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005