closestpoint

PURPOSE ^

CLOSESTPOINT - find the closest point of a profile

SYNOPSIS ^

function [profsel indsel]=closestpoint(A,numprofiles,xi,yi)

DESCRIPTION ^

CLOSESTPOINT - find the closest point of a profile

   This routine find the point of the profile A that is the closest
   to (xi,yi) and return the number of the profile and the number of
   the point

   Usage:
     [profsel indsel]=closestpoint(A,numprofiles,xi,yi)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [profsel indsel]=closestpoint(A,numprofiles,xi,yi)
0002 %CLOSESTPOINT - find the closest point of a profile
0003 %
0004 %   This routine find the point of the profile A that is the closest
0005 %   to (xi,yi) and return the number of the profile and the number of
0006 %   the point
0007 %
0008 %   Usage:
0009 %     [profsel indsel]=closestpoint(A,numprofiles,xi,yi)
0010 
0011     %loop over the points of each profile, find the closest to (xi,yi)
0012     for i=1:numprofiles,
0013         distance=(xi-A(i).x).^2+(yi-A(i).y).^2;
0014         [newdistance p]=min(distance);
0015         if ((i==1) | (newdistance<olddistance)),
0016             indsel=p;
0017             profsel=i;
0018             olddistance=newdistance;
0019         end
0020     end
0021 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003