function [ nearest ] = findNearestCluster( yt, means, vars ) % FINDNEARESTCLUSTER - % % Written by: % -- % John L. Weatherwax 2005-08-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- nClusts = size(means,1); minDist = +Inf; nearest = -1; for ci=1:nClusts, diff = (means(ci,:) - yt) ./ sqrt(vars(ci,:)); dSqr = diff * (diff.'); if( dSqr < minDist ) minDist = dSqr; nearest = ci; end end; clear minDist