From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: finding distances that satisfy the equation ? (confused :'( , please help)
Date: Sun, 28 Mar 2010 19:10:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <hoo9it$r4p$>
References: <hoo666$8u3$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1269803421 27801 (28 Mar 2010 19:10:21 GMT)
NNTP-Posting-Date: Sun, 28 Mar 2010 19:10:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:621231

"Natalie Sin Hwee " <> wrote in message <hoo666$8u3$>...
> ........
> for node=1:a; 
>     for u=1:a; 
>         theta(node,u)=atan2(imag((x(1,u)-x(1,node))+[(y(1,u)-y(1,node))*i]),...
>                         real((x(1,u)-x(1,node))+[(y(1,u)-y(1,node))*i]));
>     end
> end
> [thetasort,R]=sort(theta,1); % increasing angles downward (column)
> sect1=((0<thetasort) & (thetasort<(0.25*pi)));
  This looks like a very awkward way to compute your angles.  Why take the trouble to create complex-valued quantities only to convert them back to real values again?  Why not just say this:


  With either method you will be obtaining angles measured counterclockwise from the x-axis to the directed line between each pair of points and which range from -pi to +pi.  You will be selecting only those between 0 and +pi/4, and in particular rejecting those between -pi/4 and 0.  In the cases where node equals u along the diagonal your results will be meaningless.  Is this what you want?

  Why do you sort the angles before subjecting them to your range tests?  What you will get is a series of falses, then trues, and finally falses.  As your code stands there is no way to associate this with the original data in x and y.

Roger Stafford