From: "Damian Sheehy" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Logicals, winding number, -inpolgon
Date: Fri, 20 Mar 2009 11:23:25 -0400
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <gq0cdf$5b2$>
References: <gq085l$bpd$>
Reply-To: "Damian Sheehy" <>
X-Trace: 1237562607 5474 (20 Mar 2009 15:23:27 GMT)
NNTP-Posting-Date: Fri, 20 Mar 2009 15:23:27 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: comp.soft-sys.matlab:526449


        You simply use "logical indexing". Read the example given in the 
help for INPOLYGON.
       % Self-intersecting polygon
        xv = rand(6,1); yv = rand(6,1);
        xv = [xv ; xv(1)]; yv = [yv ; yv(1)];
        x = rand(1000,1); y = rand(1000,1);
        in = inpolygon(x,y,xv,yv);

The coordinates you are looking for are given by x(in), y(in)


"Zeinab Al-Rekabi" <> wrote in message 
> Hello
> I am trying to compute the winding number, which is the number of times 
> that a closed curve encircles the point.
> I used the matlab function [IN]=inpolygon(X,Y,xv,yv), where X,Y are the 
> points and xv,yv are the curves coutour (assuming 2d).
> I obtain a logical array nX1, which has 0s and 1s. 0s being outside the 
> countour and 1s being inside the contour. My question: how do I convert 
> such a logical array into the X,Y numbers which it originally was, so 
> baiscally for those values that were 1, how do I get their X,Y values? Is 
> there a matlab function that does this conversion and if not may anyone 
> assist me in obtaining them.
> Thank you kindly
> Z