From: "Natalie Sin Hwee " <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: finding distances that satisfy the equation ? (confused :'( , please help)
Date: Mon, 29 Mar 2010 09:56:04 +0000 (UTC)
Organization: Imperial College
Lines: 30
Message-ID: <hoptfk$7du$>
References: <hoo666$8u3$> <hoo9it$r4p$>
Reply-To: "Natalie Sin Hwee " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1269856564 7614 (29 Mar 2010 09:56:05 GMT)
NNTP-Posting-Date: Mon, 29 Mar 2010 09:56:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2069448
Xref: comp.soft-sys.matlab:621415

"Roger Stafford" <> wrote in message <hoo9it$r4p$>...
> "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:
>  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


basically i used a more 'complex' method because im working from 0-pi and 0 - (-pi) hence the atan2. im nore sure why im using the real and imaginary. apparently it will work in 3d (through my previous quetisons on the forum) - which i will later need to make my model into 3d !! ^^