1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<HTML>
<HEAD>
<TITLE>WHERE</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" fgcolor="#000000">
<P><A NAME="WHERE"></A>
<font size="+3" color="green"><B>WHERE</B></font></P>
<P>
<TABLE border="1" cols="2" frame="box" rules="all" width="572">
<TR>
<TD width="15%" valign="top"><B>Syntax</B>:</TD>
<TD width="85%"><CODE>
vout = WHERE(vector)</CODE>
</TD></TR>
</table></p>
<p>
The <CODE>WHERE</CODE> function only accepts a
vector as argument. It returns the indices where this vector is not equal
to zero.</P>
<P>
<font size="+1" color="green">Examples</font></P>
<P>
Suppose you have a vector <CODE>X = [-5:5]</CODE> and you enter
<CODE><font color="blue">Y=WHERE(X>0)</font></CODE>,
then <CODE>Y</CODE> would be <CODE>[7;8;9;10;11]</CODE> since
<CODE>X[Y] > 0</CODE>. If you enter
<CODE><font color="blue">Y=WHERE(X<=0)</font></CODE>
then <CODE>Y</CODE> would be <CODE>[1;2;3;4;5;6]</CODE> since
<CODE>X[Y] ≤ 0</CODE>.</P>
<P>
Suppose you have two vectors <CODE>X</CODE> and <CODE>Y</CODE> and you
want to graph only those points that lie within the unit circle, that is,
only those points that satisfy
<CODE>SQRT(X<sup>2</sup>+Y<sup>2</sup>) ≤ 1</CODE>.
The following commands produce the picture below.</P>
<P>
<font color="blue"><PRE>
GENERATE/RANDOM X -2 2 10000
GENERATE/RANDOM Y -2 2 10000
SET PLOTSYMBOL -17
SET %PLOTSYMBOLSIZE 0.5
SET AUTOSCALE COMMENSURATE
IDX=WHERE(SQRT(X^2+Y^2)<=1)
GRAPH X[IDX] Y[IDX]
</PRE></font></P>
<P>
<center><IMG SRC="whereI01.png"></center></P>
</BODY>
</HTML>
|