Skip to content
Snippets Groups Projects
iround_os.m 390 B
Newer Older
Olivier Sauter's avatar
Olivier Sauter committed
%
% Given two arrays sig and val, for each element in val 
% returns the index and value of the nearest element in sig.
% 
Olivier Sauter's avatar
Olivier Sauter committed
% sig and/or val can be non-monotonic (contrary to TCV iround which requires sig to be monotonic)
Olivier Sauter's avatar
Olivier Sauter committed
% >> [i,sigi]=iround_os(sig,val);
%
%
%
for j=1:length(val)
  [s(j),is(j)]=min(abs(sig-val(j)));
end
sigi=sig(is);