Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
inpolygon problems with matrix size

Subject: inpolygon problems with matrix size

From: Anthony Hopf

Date: 14 May, 2010 18:14:21

Message: 1 of 4

This one is obviously confusing me, since I am posting here.

I'm using inpolygon to evaluate some points on a theta, phi plot. I am evaluating tempaz and tempel against az and el points. Tempaz, tempel, az, and el can have NaN values, but the NaN values correspond so there is no value in tempaz that corresponds to a NaN in tempel... same for az,el.

tempaz is 1x250000
tempel is 1x250000

az is 1x6
el is 1x6

my inpolygon line of code is:

[in on] = inpolygon(tempaz,tempel,az,el);

and I get:
??? Error using ==> minus
Matrix dimensions must agree.

Error in ==> inpolygon>vec_inpolygon at 174
xv = xv(:,ones(1,Np)) - x;

Error in ==> inpolygon at 115
        [in on] = vec_inpolygon(Nv,x,y,xv,yv);

any ideas?

Thank you,

Tony

Subject: inpolygon problems with matrix size

From: Loren Shure

Date: 14 May, 2010 18:25:11

Message: 2 of 4

In article <hsk3tt$65h$1@fred.mathworks.com>, anthony.hopf@gmail.com
says...
> This one is obviously confusing me, since I am posting here.
>
> I'm using inpolygon to evaluate some points on a theta, phi plot. I am evaluating tempaz and tempel against az and el points. Tempaz, tempel, az, and el can have NaN values, but the NaN values correspond so there is no value in tempaz that corresponds to a NaN in tempel... same for az,el.
>
> tempaz is 1x250000
> tempel is 1x250000
>
> az is 1x6
> el is 1x6
>
> my inpolygon line of code is:
>
> [in on] = inpolygon(tempaz,tempel,az,el);
>
> and I get:
> ??? Error using ==> minus
> Matrix dimensions must agree.
>
> Error in ==> inpolygon>vec_inpolygon at 174
> xv = xv(:,ones(1,Np)) - x;
>
> Error in ==> inpolygon at 115
> [in on] = vec_inpolygon(Nv,x,y,xv,yv);
>
> any ideas?
>
> Thank you,
>
> Tony
>

Try transposing az and el and making them row vectors. If that works,
please submit a bug report describing the issue, since the reference
page doesn't say anything about the shape of xv, yv.

--
Loren
http://blogs.mathworks.com/loren
http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: inpolygon problems with matrix size

From: Anthony Hopf

Date: 14 May, 2010 18:40:22

Message: 3 of 4

Loren Shure <loren.shure@mathworks.com> wrote in message <MPG.26575f7ff95cf571989aec@news.mathworks.com>...
> In article <hsk3tt$65h$1@fred.mathworks.com>, anthony.hopf@gmail.com
> says...
> > This one is obviously confusing me, since I am posting here.
> >
> > I'm using inpolygon to evaluate some points on a theta, phi plot. I am evaluating tempaz and tempel against az and el points. Tempaz, tempel, az, and el can have NaN values, but the NaN values correspond so there is no value in tempaz that corresponds to a NaN in tempel... same for az,el.
> >
> > tempaz is 1x250000
> > tempel is 1x250000
> >
> > az is 1x6
> > el is 1x6
> >
> > my inpolygon line of code is:
> >
> > [in on] = inpolygon(tempaz,tempel,az,el);
> >
> > and I get:
> > ??? Error using ==> minus
> > Matrix dimensions must agree.
> >
> > Error in ==> inpolygon>vec_inpolygon at 174
> > xv = xv(:,ones(1,Np)) - x;
> >
> > Error in ==> inpolygon at 115
> > [in on] = vec_inpolygon(Nv,x,y,xv,yv);
> >
> > any ideas?
> >
> > Thank you,
> >
> > Tony
> >
>
> Try transposing az and el and making them row vectors. If that works,
> please submit a bug report describing the issue, since the reference
> page doesn't say anything about the shape of xv, yv.
>
> --
> Loren
> http://blogs.mathworks.com/loren
> http://matlabwiki.mathworks.com/MATLAB_FAQ

Loren,

I tried that, transpose xv and yv. then transpose x and y. or transpose all of the vectors.

I'll keep at it and let you know if I figure it out.

Thank you

T

Subject: inpolygon problems with matrix size

From: Anthony Hopf

Date: 14 May, 2010 18:48:04

Message: 4 of 4

"Anthony Hopf" <anthony.hopf@gmail.com> wrote in message <hsk5em$gcp$1@fred.mathworks.com>...
> Loren Shure <loren.shure@mathworks.com> wrote in message <MPG.26575f7ff95cf571989aec@news.mathworks.com>...
> > In article <hsk3tt$65h$1@fred.mathworks.com>, anthony.hopf@gmail.com
> > says...
> > > This one is obviously confusing me, since I am posting here.
> > >
> > > I'm using inpolygon to evaluate some points on a theta, phi plot. I am evaluating tempaz and tempel against az and el points. Tempaz, tempel, az, and el can have NaN values, but the NaN values correspond so there is no value in tempaz that corresponds to a NaN in tempel... same for az,el.
> > >
> > > tempaz is 1x250000
> > > tempel is 1x250000
> > >
> > > az is 1x6
> > > el is 1x6
> > >
> > > my inpolygon line of code is:
> > >
> > > [in on] = inpolygon(tempaz,tempel,az,el);
> > >
> > > and I get:
> > > ??? Error using ==> minus
> > > Matrix dimensions must agree.
> > >
> > > Error in ==> inpolygon>vec_inpolygon at 174
> > > xv = xv(:,ones(1,Np)) - x;
> > >
> > > Error in ==> inpolygon at 115
> > > [in on] = vec_inpolygon(Nv,x,y,xv,yv);
> > >
> > > any ideas?
> > >
> > > Thank you,
> > >
> > > Tony
> > >
> >
> > Try transposing az and el and making them row vectors. If that works,
> > please submit a bug report describing the issue, since the reference
> > page doesn't say anything about the shape of xv, yv.
> >
> > --
> > Loren
> > http://blogs.mathworks.com/loren
> > http://matlabwiki.mathworks.com/MATLAB_FAQ
>
> Loren,
>
> I tried that, transpose xv and yv. then transpose x and y. or transpose all of the vectors.
>
> I'll keep at it and let you know if I figure it out.
>
> Thank you
>
> T

Loren,

I figured out the problem. one of my values tempaz was a different class. Changed it back to a double and everything worked.

Thanks again,

Tony

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us