Path: news.mathworks.com!not-for-mail 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$1@fred.mathworks.com> References: <hoo666$8u3$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1269803421 27801 172.30.248.38 (28 Mar 2010 19:10:21 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 28 Mar 2010 19:10:21 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:621231 "Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> wrote in message <hoo666$8u3$1@fred.mathworks.com>... > ........ > 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: theta(node,u)=atan2(y(u)-y(node),x(u)-x(node)); 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