Re: [Scilab-users] Extract closest value

2022-06-02 Thread Lester Anderson
Hi Serge, Thanks for the suggestion. I did find another method that also works via a for-loop: e.g. x=[1 2 3 4 5];y=[0 1.1 1.5 1.6 2.4 4.1 4.7 5 5.7];for k=1:length(x) [val,idx]=min(abs(y-x(k))); xx(k)=y(idx);end Lester On Thu, 2 Jun 2022 at 11:37, Steer Serge wrote: > If A and B are not

[Scilab-users] Extract closest value

2022-06-02 Thread Lester Anderson
Hi all, Is it possible to use one vector to find only those closest values in another vector with a tolerance limit? A=[2 3 4 5 6]; // source array B=[0.25 1.2 2.01 5.2 7.4 9.3 10.6 ]; // target array to find closest values to A So in the example above, the closest values would be 2.01 and 5.2