[scilab-Users] test if a value is between two others

Mike Page Mike at Page-One.Waitrose.com
Thu Mar 10 12:21:54 CET 2011


Hi Loic,

Your code seems wrong.  Why do you have T(j) instead of T(i) in the second
test?  What is the variable ae?

Anyway, the best way is probably to use find, like:

find((t>a-tol)&(t<a+tol)).

This returns a vector of the indices of t that are between a-tol and a+tol.

Regards,
Mike.

  -----Original Message-----
  From: Loïc GIROD [mailto:Loic.Girod at esstin.uhp-nancy.fr]
  Sent: 10 March 2011 10:57
  To: users at lists.scilab.org
  Subject: [scilab-Users] test if a value is between two others


  Hi everyone,



  I’m trying to test if a value a can be located in an array of values
(named T). As my reference value a can not be really equal to a value in
T(i), I apply a tolerance factor.

  So, I have to know if my value T(i) is between a+tolerance and
a-tolerance.



  I’ve tried the following code :



  for i=1:size(T)

      if T(i)>=a+tolerance

          then if T(j)<=ae-tolerance then location=i

          end

      end

  end



  I get an error 34 and I don’t understand how to solve it. I’ve tried while
function, but it returns nothing.



  Could someone help me ?



  Many thanks



  Best regards





  Loïc






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110310/7f41fd24/attachment.htm>


More information about the users mailing list