Date: Jun 16, 2013 3:34 AM
Author: Bruno Luong
Subject: Re: match matrix to closest values

"Y " <nospamhere@dispostable.org> wrote in message <kphglh$klb$1@newscl01ah.mathworks.com>...
>
> That's a good way to use interp1 I wasn't aware of, thanks.
> Do you have a suggestion on how to get back the indices back from interp1? Or is the best one find(ismember(h,val))?


Simply do this:

idx = interp1(h,1:length(h),needle,'nearest')

% Bruno