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);