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:
generate set of points, plots

Subject: generate set of points, plots

From: Stefan

Date: 19 Aug, 2010 14:52:09

Message: 1 of 5

Hello,
I was wondering how to solve this problem.

[x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
I would like to store all the points (x,y) generated by the meshgrid function above such that x<-0.5*y*abs(y).

Thanks

Subject: generate set of points, plots

From: John D'Errico

Date: 19 Aug, 2010 15:00:35

Message: 2 of 5

"Stefan " <akinsakin@yahoo.com> wrote in message <i4jgep$lg1$1@fred.mathworks.com>...
> Hello,
> I was wondering how to solve this problem.
>
> [x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
> I would like to store all the points (x,y) generated by the meshgrid function above such that x<-0.5*y*abs(y).
>
> Thanks

So try it!

What does this produce?

   k = x < (-0.5*y*abs(y));

Now, suppose you tried this?

  [x(k), y(k)]

Any guesses what it might do? TRY IT.

John

Subject: generate set of points, plots

From: Andy

Date: 19 Aug, 2010 15:00:35

Message: 3 of 5

"Stefan " <akinsakin@yahoo.com> wrote in message <i4jgep$lg1$1@fred.mathworks.com>...
> Hello,
> I was wondering how to solve this problem.
>
> [x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
> I would like to store all the points (x,y) generated by the meshgrid function above such that x<-0.5*y*abs(y).
>
> Thanks

[x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
idx = x<-0.5*y*abs(y);
x=x(idx);
y = y(idx);

I'm not currently at MATLAB. You may need to do some sub2ind or ind2sub in here somewhere.

Subject: generate set of points, plots

From: Sean

Date: 19 Aug, 2010 15:04:06

Message: 4 of 5

"Stefan " <akinsakin@yahoo.com> wrote in message <i4jgep$lg1$1@fred.mathworks.com>...
> Hello,
> I was wondering how to solve this problem.
>
> [x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
> I would like to store all the points (x,y) generated by the meshgrid function above such that x<-0.5*y*abs(y).
>
> Thanks

Like this:

idx = find(x< -.5*y.*abs(y));
[x(idx), y(idx)]

Subject: generate set of points, plots

From: John D'Errico

Date: 19 Aug, 2010 15:33:10

Message: 5 of 5

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i4jh56$90n$1@fred.mathworks.com>...
> "Stefan " <akinsakin@yahoo.com> wrote in message <i4jgep$lg1$1@fred.mathworks.com>...
> > Hello,
> > I was wondering how to solve this problem.
> >
> > [x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
> > I would like to store all the points (x,y) generated by the meshgrid function above such that x<-0.5*y*abs(y).
> >
> > Thanks
>
> Like this:
>
> idx = find(x< -.5*y.*abs(y));
> [x(idx), y(idx)]

You don't need to use find at all.

The direct index is faster.

And no use of sub2ind or ind2sub is necessary.

John

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