COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### inpolygon help

• Email
• Follow

```I am trying to use the inpolygon command. I want it to eventually be used in a function where the user passes the dimensions of an image to it. It will also be passed several points that the user selected with ginput.

However, I am unsure of how to use inpolygon. From the way I understand it,

IN = inpolygon(X,Y,xv,yv)

X and Y must be the same size, and X represents the x value at each point in the matrix, and Y represents the y values in the matrix. xv is a vector containing the x-values of the user defined points, and yv is a vector containing the y-values of the user defined points.

This is how I am trying to implement it:

matrix=zeros(14,8); % 14 and 8 will eventually be passed as variables to the function
x=[3,1,5,6];           % x and y will eventually be vectors passed as variables
y=[1,6,11,7];         % to the function

%The following creates the matrixes X and Y for inpolygon
[rows,cols]=size(matrix);
for i=1:1:cols
xvals=i;
end
for i=1:1:rows
yvals=i;
end
yvals=yvals';
[Xvals,Yvals]=meshgrid(xvals,yvals);

xpoint=x+1; %Because the user defined inputs have the reference at 0,0
ypoint=y+1; %and the matrixes will be indexed from variable(1,1)

matrix=inpolygon(Xvals,Yvals,xpoint,ypoint)

However I get the following error/output

??? Error using ==> and
Inputs must have the same size.

Error in ==> inpolygon at 77
mask = (x >= min(xv)) & (x <= max(xv)) &
(y>=min(yv)) & (y<=max(yv));

Error in ==> mask at 54
matrix=inpolygon(rows,cols,xpoint,ypoint)

matrix =

0

EDU>>
```
 0
Reply Nicholas 1/9/2011 1:09:04 AM

See related articles to this posting

```"Nicholas Trunfio" <Nicholas_Trunfio@student.uml.edu> wrote in message <igb1rg\$rlp\$1@fred.mathworks.com>...

> for i=1:1:cols
>     xvals=i;
> end
> for i=1:1:rows
>     yvals=i;
> end

Your loop erase data over an over.

Beside that the code runs. You probably make another mistake when test it.

Bruno
```
 0
Reply Bruno 1/9/2011 10:20:21 AM

1 Replies
850 Views

Similar Articles

12/7/2013 2:36:05 AM
[PageSpeed]

Similar Artilces:

Fw: How does compare work?..Of no help, but...
of no help, so just <snip> if you hate that sort of thing... if 2 > '1' : print "greater" else : print "less_or_equal" prints less_or_equal As it should, because the condition 2>'1' is not true.. Give a machine a conditional statement that doesn't return true, followed by an else... etc Under most circumstances, python is fairly logical. In this case, too. However... class C: def __init__(self): pass X=C() if 2 > X : print "greater" prints greater Now *here* I see exactly what you're saying. I'd noticed this slight oddness too.. First example doesn't really exhibit the behaviour, but this one bothers slightly. I'm not really on top of the technical stuff about python, but I'd had all sorts of obvious thoughts about this one like could the comparison be taking an instance to have 'no' numerical value ie 'none' when using some particular comparison method? I'd be interested to know this one myself... ============================= M. Harris Sr Developer DNM, Inc.

HELP!!! Interfacing Virtex-4 FPGA with SDR SDRAM
Hello ALL, This is my second message :( I did not get answer for the first one, so I am sending it again. My be it got lost somewhere in news-server, or this is not the right NG to post this message. Any way, people here are talking about FPGA and SDRAM adn this is my current problem. I am having hard time designing the schematic to interface conventional SDRAM chip to Virtex-4 FPGA. As a SDRAM we have selected Micron 256Mbit part with 32 bit wide data bus. Both packages a BGA, Virtex-4 is FF-672 type, SDRAM is FBGA-90. Our chips is planned to be located about 5-10mm (0.2-0.4 inches) from ea

Oilpainting
tut is 6 years out of date. Not the definitive word anyway. I may be able to help you if you write me, with, specific things, you'd like to do. Greg. > The main problem is that there are lots of tutorials which tell me how > to use different things in Psp, like picture tubes, brushes, etc.. > But I have found no tutorials that start from what I need, only from > what is available in the program. > > Is there any tutorial, web site, which starts from the real world > technique of painting and shows how to do the same, or similar, things > in Psp? > >

sweetkiss
www.flogvip.net/sweetkiss www.flogvip.net/sweetkiss www.flogvip.net/sweetkiss www.flogvip.net/sweetkiss www.flogvip.net/sweetkiss www.flogvip.net/sweetkiss

Saving as
, Florida I found this: http://www.hyperionics.com/files/downloads.asp It takes a little getting used to but it's free, low profile and doing want I wanted it to do. So far it works across all the applications I have tested. One cool thing is that it has its own 'open recent' options. I'm a big fan of open recent because I work by project so this will allow me to cross projects. I will see if it behaves itself. Thanks to everyone for their help Btw, that link may require a cookie. If it does not work just google FileBox eXtender. <ronviers@gmail.com> wrote in message news:492c5eab-f49a-41fe-951d-4e22e5d723b0@d70g2000hsb.googlegroups.com... >I found this: > http://www.hyperionics.com/files/downloads.asp > It takes a little getting used to but it's free, low profile and doing > want I wanted it to do. So far it works across all the applications I > have tested. One cool thing is that it has its own 'open recent' > options. I'm a big fan of open recent because I work by project so > this will allow me to cross projects. I will see if it behaves itself. > > Thanks to everyone for their help > > Btw, that link may

Tezt
Tezt

LOOK!!!
FREE Mobile Phones: Which one is for you? Choose your mobile phone make or network Select a makeBlackberry HTC Levi LG Mandarina Duck Motorola Nokia O2 Palm Prada Samsung Sony Eric. Talk Mobile Virgin Mob Blackberry HTC Levi LG Mandarina Duck Motorola Nokia O2 Palm Prada Samsung Sony Eric. Talk Mobile Virgin Mob Select a networkO2 Orange T-Mobile Talk Mobile Virgin Mobile O2 Orange T-Mobile Talk Mobile Virgin Mobile Nokia N95 6 Months 1/2 Price by redemption 500 mins & Unlimited texts per month Micro SD card support 160MB internal memory High-resolution colour display Bluetooth(tm)

CPYTOIMPF
Dear Lords! I try to create an importfile using: CPYTOIMPF FROMFILE(MHIS400FIL/EISART) TOSTMF('/tmp/test/eisart') MBROPT (*REPLACE) STMFCODPAG(*PCASCII) RCDDLM(*CRLF) DTAFMT(*DLM) STRDLM('[') DECPNT(*COMMA) but everytime get the error: Reason Code 5: Delimiter for DTAFMT(*DLM) not valid. When i try to use *FIXED, it works fine, but then i dont have delimiters, so i cannot import (csv) it into an application, lets say mysql. Any hints? -- Und wenn du zu lange in einen Abgrund blickst, dann blickt der Abgrund auch in dich hinein. Ivo Angelo Carobbio racontait dans com

with what...
what program use to edit myself an applet... Yours : JariTapio I hav file called --- logo.java --- how to compile it to --- logo.class --- what program to use... JariTapio <JariTapio@pp.inet.fi> wrote: > I hav file called --- logo.java --- > how to compile it to --- logo.class --- > what program to use... Both this question and the question in the original post are answered in any starting tutorial, most likely also the one provided by Sun. Let's search their website: - Go to the Java website: http://java.sun.com/ - Type "java tutorial" in the search box - Go to the first result - Look for this text: "Detailed instructions to help you run your first program" Pretty easy search I'd say... -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 On Fri, 25 Feb 2005 18:01:44 GMT, "JariTapio" <JariTapio@pp.inet.fi> wrote: >I hav file called --- logo.java --- >how to compile it to --- logo.class --- >what program to use

ListIntegrate
`ListIntegrate` gives me this error, sometimes it doesn't, but I've seen ListIntegrate give me the answer w/ and w/out this error: SetDelayed:write: Tag ListIntegrate in ListIntegrate[c]_?VectorQ, h_,k_Integer : 3] is Protected. Obviously I'm a noob and I need some real help here. Thanks very much. grant Hi, the culprit is the package "ListIntegrate" that is not properly written. You may read this package once, but you get an error messages if you read it a second time. The reason is that at the end of this package a number of symbols, that are defined...` gives me this error, sometimes it doesn't, but I've seen ListIntegrate give me the answer w/ and w/out this error: > > SetDelayed:write: > Tag ListIntegrate in ListIntegrate[c]_?VectorQ, > h_,k_Integer : 3] is Protected. > > Obviously I'm a noob and I need some real help here. Thanks very much. grant >