-
Olivier Sauter authored
git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@12244 d63d8f72-b253-0410-a779-e742ad2e26cf
Olivier Sauter authoredgit-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@12244 d63d8f72-b253-0410-a779-e742ad2e26cf
iround_os.m 390 B
function [is,sigi]=iround_os(sig,val)
%
% Given two arrays sig and val, for each element in val
% returns the index and value of the nearest element in sig.
%
% sig and/or val can be non-monotonic (contrary to TCV iround which requires sig to be monotonic)
%
% Example:
%
% >> [i,sigi]=iround_os(sig,val);
%
%
%
for j=1:length(val)
[s(j),is(j)]=min(abs(sig-val(j)));
end
sigi=sig(is);