<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word" xmlns:m = 
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1649" name=GENERATOR>
<STYLE>@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@font-face {
        font-family: Monospaced;
}
@page WordSection1 {size: 612.0pt 792.0pt; margin: 70.85pt 70.85pt 70.85pt 70.85pt; }
P.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"; mso-fareast-language: EN-US
}
LI.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"; mso-fareast-language: EN-US
}
DIV.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"; mso-fareast-language: EN-US
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
PRE {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "Préformaté HTML Car"
}
P.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-fareast-language: EN-US; mso-style-priority: 99; mso-style-link: "Texte de bulles Car"
}
LI.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-fareast-language: EN-US; mso-style-priority: 99; mso-style-link: "Texte de bulles Car"
}
DIV.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-fareast-language: EN-US; mso-style-priority: 99; mso-style-link: "Texte de bulles Car"
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-compose
}
SPAN.TextedebullesCar {
        FONT-FAMILY: "Tahoma","sans-serif"; mso-style-priority: 99; mso-style-link: "Texte de bulles"; mso-style-name: "Texte de bulles Car"
}
SPAN.PrformatHTMLCar {
        FONT-FAMILY: "Courier New"; mso-fareast-language: FR; mso-style-priority: 99; mso-style-link: "Préformaté HTML"; mso-style-name: "Préformaté HTML Car"
}
.MsoChpDefault {
        FONT-FAMILY: "Calibri","sans-serif"; mso-fareast-language: EN-US; mso-style-type: export-only
}
DIV.WordSection1 {
        page: WordSection1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=FR vLink=purple link=blue>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff size=2>Hi 
Loic,</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff size=2>Your 
code seems wrong.  Why do you have T(j) instead of T(i) in the second 
test?  What is the variable ae?</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2>Anyway, the best way is probably to use find, like:</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2>find((t>a-tol)&(t<a+tol)).</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff size=2>This 
returns a vector of the indices of t that are between a-tol and 
a+tol.</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011><FONT face=Arial color=#0000ff 
size=2>Mike.</FONT></SPAN></DIV>
<DIV><SPAN class=765042011-10032011></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Loïc GIROD 
  [mailto:Loic.Girod@esstin.uhp-nancy.fr]<BR><B>Sent:</B> 10 March 2011 
  10:57<BR><B>To:</B> users@lists.scilab.org<BR><B>Subject:</B> [scilab-Users] 
  test if a value is between two others<BR><BR></FONT></DIV>
  <DIV class=WordSection1>
  <P class=MsoNormal>Hi everyone, <o:p></o:p></P>
  <P class=MsoNormal><o:p> </o:p></P>
  <P class=MsoNormal><SPAN lang=EN-US>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.<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>So, I have to know if my value T(i) is 
  between a+tolerance and a-tolerance.<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>I’ve tried the following code : 
  <o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; COLOR: #a020f0; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">for</SPAN><SPAN 
  lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR"> 
  <SPAN style="COLOR: black">i</SPAN><SPAN style="COLOR: #5c5c5c">=</SPAN><SPAN 
  style="COLOR: black">1</SPAN><SPAN style="COLOR: #ffaa00">:</SPAN><SPAN 
  style="COLOR: black">size(T)</SPAN><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">    
  <SPAN style="COLOR: #a020f0">if</SPAN> <SPAN 
  style="COLOR: black">T</SPAN><SPAN style="COLOR: #4a55db">(</SPAN><SPAN 
  style="COLOR: black">i</SPAN><SPAN style="COLOR: #4a55db">)</SPAN><SPAN 
  style="COLOR: #5c5c5c">>=</SPAN><SPAN style="COLOR: black">a</SPAN><SPAN 
  style="COLOR: #5c5c5c">+</SPAN><SPAN 
  style="COLOR: black">tolerance</SPAN><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">        
  <SPAN style="COLOR: #a020f0">then</SPAN> <SPAN 
  style="COLOR: #a020f0">if</SPAN> <SPAN style="COLOR: black">T</SPAN><SPAN 
  style="COLOR: #4a55db">(</SPAN><SPAN style="COLOR: black">j</SPAN><SPAN 
  style="COLOR: #4a55db">)</SPAN><SPAN style="COLOR: #5c5c5c"><=a</SPAN><SPAN 
  style="COLOR: black">e</SPAN><SPAN style="COLOR: #5c5c5c">-</SPAN><SPAN 
  style="COLOR: black">tolerance</SPAN> <SPAN style="COLOR: #a020f0">then</SPAN> 
  <SPAN style="COLOR: black">location</SPAN><SPAN 
  style="COLOR: #5c5c5c">=</SPAN><SPAN 
  style="COLOR: black">i</SPAN><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">        
  <SPAN style="COLOR: #a020f0">end</SPAN><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">    
  <SPAN style="COLOR: #a020f0">end</SPAN><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="FONT-SIZE: 10.5pt; COLOR: #a020f0; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR">end</SPAN><SPAN 
  lang=EN-US 
  style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Monospaced','serif'; mso-fareast-language: FR"><o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>I get an error 34 and I don’t understand 
  how to solve it. I’ve tried while function, but it returns 
  nothing.<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>Could someone help me 
  ?<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>Many thanks<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US>Best regards<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="mso-fareast-language: FR">Loïc<o:p></o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="mso-fareast-language: FR"><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><SPAN lang=EN-US 
  style="mso-fareast-language: FR"><o:p> </o:p></SPAN></P>
  <P class=MsoNormal><o:p> </o:p></P></DIV></BLOCKQUOTE></BODY></HTML>