[Master Index] [Index for Toolbox]

# findclosest

## (Toolbox/findclosest.m in BrainStorm 2.0 (Alpha))

### Function Synopsis

    VecInd  = findclosest(VecGuess, VecRef);

### Help Text

    FINDCLOSEST - Find entries of closest elements between two vectors
     function VecInd  = findclosest(VecGuess, VecRef);
     Find entries of closest elements between two vectors
     VecGuess is a vector for which one wants to find the closest entries in vector VecRef
     VecInd is the vector of indices pointing atr the entries in vector VecRef that are the closest to VecWin
     VecInd is of the length of VecGuess

     In other words, VecRef(VecInd(i)) is the element of VecRef closest to VecGuess(j)

     VecRef and VecGuess do not need to be the same length

### Cross-Reference Information

This function is called by

    bst_sourceimaging                  C:\BrainStorm_2001\Toolbox\bst_sourceimaging.m
    bst_wavedata_display               C:\BrainStorm_2001\Toolbox\bst_wavedata_display.m
    dataplot_cb                        C:\BrainStorm_2001\Toolbox\dataplot_cb.m
    ds2brainstorm                      C:\BrainStorm_2001\Toolbox\ds2brainstorm.m
    importdata                         C:\BrainStorm_2001\Toolbox\importdata.m
    manage_corticalscouts              C:\BrainStorm_2001\Toolbox\manage_corticalscouts.m
    zscore_gui                         C:\BrainStorm_2001\Toolbox\zscore_gui.m

### Listing of function C:\BrainStorm_2001\Toolbox\findclosest.m

    function VecInd  = findclosest(VecGuess, VecRef);
    %FINDCLOSEST - Find entries of closest elements between two vectors
    % function VecInd  = findclosest(VecGuess, VecRef);
    % Find entries of closest elements between two vectors
    % VecGuess is a vector for which one wants to find the closest entries in vector VecRef
    % VecInd is the vector of indices pointing atr the entries in vector VecRef that are the closest to VecWin
    % VecInd is of the length of VecGuess
    %
    % In other words, VecRef(VecInd(i)) is the element of VecRef closest to VecGuess(j)
    %
    % VecRef and VecGuess do not need to be the same length

    %<autobegin> ---------------------- 09-Jul-2004 22:17:04 -----------------------
    % --------- Automatically Generated Comments Block Using AUTO_COMMENTS ---------
    %
    % CATEGORY: Utility - Numeric
    %
    % At Check-in: $Author: Mosher $  $Revision: 11 $  $Date: 7/09/04 8:42p $
    %
    % This software is part of BrainStorm Toolbox Version 2.0 (Alpha) 09-Jul-2004
    %
    % Principal Investigators and Developers:
    % ** Richard M. Leahy, PhD, Signal & Image Processing Institute,
    %    University of Southern California, Los Angeles, CA
    % ** John C. Mosher, PhD, Biophysics Group,
    %    Los Alamos National Laboratory, Los Alamos, NM
    % ** Sylvain Baillet, PhD, Cognitive Neuroscience & Brain Imaging Laboratory,
    %    CNRS, Hopital de la Salpetriere, Paris, France
    %
    % See BrainStorm website at http://neuroimage.usc.edu for further information.
    %
    % Copyright (c) 2004 BrainStorm by the University of Southern California
    % This software distributed  under the terms of the GNU General Public License
    % as published by the Free Software Foundation. Further details on the GPL
    % license can be found at http://www.gnu.org/copyleft/gpl.html .
    %
    % FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE
    % UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY
    % WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
    % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY
    % LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE.
    %<autoend> ------------------------ 09-Jul-2004 22:17:04 -----------------------

    if size(VecRef,1) == 1
        VecRef = VecRef';
    end

    tmp = repmat(VecRef,1,length(VecGuess));
    [minn VecInd] = min(abs(repmat(VecGuess,length(VecRef),1) - tmp));

    return

Produced by color_mat2html, a customized BrainStorm 2.0 (Alpha) version of mat2html on Tue Nov 2 16:17:59 2004
Cross-Directory links are: ON