<div dir="ltr">Hi Serge,<div><br></div><div>Thanks for the suggestion. I did find another method that also works via a for-loop:</div><div>e.g. </div><div><pre style="font-family:Arial"><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">1</span> <span style="color:rgb(188,143,143)">2</span> <span style="color:rgb(188,143,143)">3</span> <span style="color:rgb(188,143,143)">4</span> <span style="color:rgb(188,143,143)">5</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">y</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">0</span> <span style="color:rgb(188,143,143)">1.1</span> <span style="color:rgb(188,143,143)">1.5</span> <span style="color:rgb(188,143,143)">1.6</span> <span style="color:rgb(188,143,143)">2.4</span> <span style="color:rgb(188,143,143)">4.1</span> <span style="color:rgb(188,143,143)">4.7</span> <span style="color:rgb(188,143,143)">5</span> <span style="color:rgb(188,143,143)">5.7</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(160,32,240)">for</span> <span style="color:rgb(0,0,0)">k</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(255,170,0)">:</span><span style="color:rgb(50,185,185)">length</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(74,85,219)">)</span>
  <span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">val</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">idx</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">min</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(50,185,185)">abs</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">y</span><span style="color:rgb(92,92,92)">-</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">k</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
  <span style="color:rgb(0,0,0)">xx</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">k</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(0,0,0)">y</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">idx</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(160,32,240)">end</span></pre>Lester</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 2 Jun 2022 at 11:37, Steer Serge <<a href="mailto:Serge.Steer@laposte.net">Serge.Steer@laposte.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <div>If A and B are not too big you can
      proceed as follow:<br>
      E=abs(ones(B')*A-B'*ones(A))<br>
      <br>
      [i,j]=ind2sub(find(E<=0.3),size(E));<br>
      Serge<br>
      <br>
      Le 02/06/2022 à 10:17, Lester Anderson a écrit :<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hi all,
        <div><br>
        </div>
        <div>Is it possible to use one vector to find only those closest
          values in another vector with a tolerance limit?</div>
        <div><br>
        </div>
        <div>A=[2 3 4 5 6]; // source array <br>
        </div>
        <div>B=[0.25 1.2 2.01 5.2 7.4 9.3 10.6 ]; // target array to
          find closest values to A<br>
        </div>
        <div><br>
        </div>
        <div>So in the example above, the closest values would be 2.01
          and 5.2 in B, all other values excluded. Arrays are not going
          to be the same size! Hopefully I have explained it well
          enough.</div>
        <div><br>
        </div>
        <div>Thanks</div>
        <div>Lester</div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
users mailing list
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>
</blockquote></div>