From e873daa893cd5a1269b03cc7ee6a07cc30205f38 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Mon, 14 Mar 2022 16:00:54 +0100
Subject: [PATCH] update from CHEASEgui

---
 matlab/iround_os.m | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/matlab/iround_os.m b/matlab/iround_os.m
index c9680680..0b9d1b10 100644
--- a/matlab/iround_os.m
+++ b/matlab/iround_os.m
@@ -1,8 +1,8 @@
 function  [is,sigi]=iround_os(sig,val)
 %
-% Given two arrays sig and val, for each element in 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:
@@ -11,7 +11,8 @@ function  [is,sigi]=iround_os(sig,val)
 %
 %
 %
-for j=1:length(val)
-  [s(j),is(j)]=min(abs(sig-val(j)));
+is = zeros(size(val));
+for j=1:numel(val)
+  [~,is(j)]=min(abs(sig-val(j)));
 end
 sigi=sig(is);
-- 
GitLab