Rank: 1469 based on 55 downloads (last 30 days) and 1 file submitted
photo

Thomas Benson

E-mail
Company/University
HR Wallingford

Personal Profile:
Professional Interests:
Oceanography, estuary science, mud, in situ instrumentation

 

Watch this Author's files

 

Files Posted by Thomas
Updated   File Tags Downloads
(last 30 days)
Comments Rating
23 Dec 2002 findnearest.m Find the nearest value in an array to a test value. Author: Thomas Benson approximation, interpolation, find nearest, array, bias argument, test value 55 3
  • 4.0
4.0 | 2 ratings
Comments and Ratings on Thomas' Files View all
Updated File Comment by Comments Rating
28 Aug 2009 findnearest.m Find the nearest value in an array to a test value. Author: Thomas Benson Jayaram, PraveenKumar

Great component!
This solved my problem...

24 Mar 2005 findnearest.m Find the nearest value in an array to a test value. Author: Thomas Benson Leon, Felipe

A bit slow, but works great for my needs. If there is a optimal (faster) way of doing this, will someone please share.

Ran into a small issue with repeated values, where it returned more than one value, causing an error in my routine. This can be corrected on my end, but to do so in here, I just changed the code a little bit (as below):

if nargout==1 | nargout==0
    
    if all(isinf(srcharray(:)))
        r = [];
    else
        clear r_temp;
        r_temp = find(abs(srcharray)==min(abs srcharray(:))));
        if length(r_temp)>1
             r = r_temp(1);
        else
             r = r_temp;
        end
    end
end

18 Dec 2004 findnearest.m Find the nearest value in an array to a test value. Author: Thomas Benson Hartwell, Glenn

Good function! It does just what I need.

Top Tags Applied by Thomas
approximation, array, bias argument, find, find nearest
Files Tagged by Thomas
Updated   File Tags Downloads
(last 30 days)
Comments Rating
23 Dec 2002 findnearest.m Find the nearest value in an array to a test value. Author: Thomas Benson approximation, interpolation, find nearest, array, bias argument, test value 55 3
  • 4.0
4.0 | 2 ratings

Contact us at files@mathworks.com