Skip to content
Snippets Groups Projects
Commit f1f0c65e authored by Olivier Sauter's avatar Olivier Sauter
Browse files

add iround_os.m to find index and values closest to target values in an array,...

add iround_os.m to find index and values closest to target values in an array, being monotonic or not

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@5294 d63d8f72-b253-0410-a779-e742ad2e26cf
parent 41e3662c
No related branches found
No related tags found
No related merge requests found
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
%
% 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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment