Path: news.mathworks.com!not-for-mail From: "Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> Newsgroups: comp.soft-sys.matlab Subject: Re: finding distances that satisfy the equation ? (confused :'( , please help) Date: Mon, 29 Mar 2010 10:01:07 +0000 (UTC) Organization: Imperial College Lines: 44 Message-ID: <hoptp3$c4p$1@fred.mathworks.com> References: <hoo666$8u3$1@fred.mathworks.com> <hoo796$od9$1@fred.mathworks.com> Reply-To: "Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1269856867 12441 172.30.248.35 (29 Mar 2010 10:01:07 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 29 Mar 2010 10:01:07 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2069448 Xref: news.mathworks.com comp.soft-sys.matlab:621418 > a hint: > - create a list [IR,IC] of those nodes only that satisfy your condition... > - then, compute their distance in a simple loop... > > [ir,ic]=find(sect1); > lst=[ir,ic]; > % now, loop through your list LST... > > just a thought... > us ===== thanks us!! i did that and it works!!!!! awesome!! ive added in: sect1=((0<theta) & (theta<(0.25*pi))); [g1,k1]=find(sect1>=1); first=[g1,k1]; first_sort=sort(first,2); L1=length(k1); dist1=zeros(L1,1); for n=1:L1 dist1(n,1)=sqrt((x(1,first_sort(n,2))-x(1,first_sort(n,1))).^2+... (y(1,first_sort(n,2))-y(1,first_sort(n,1))).^2); end and that returns me a the 'distance between nodes' corresponding to what i've found in 'first' - column1 wrt to column 2 'nodes' any idea how i can separate them out into the different 'nodes' wrt to column 1. e.g. node 1 + 2,7,8,9,(random whatever it has given me) my aim is to find, the nearest node to each node within that angle (0 to pi/4)... (will be repeated as applied to the 8 sectors in the circle) *omg sorry this is getting more and more confusing !! ^^ thanks lots just for reading through it! Natalie