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:
Help: What is meshgrid used for?

Subject: Help: What is meshgrid used for?

From: wjgoh@gdnmail.net (Wee Jin Goh)

Date: 24 Mar, 2004 08:33:45

Message: 1 of 5

I'm trying to do a field plot of the Rossler attractor. After looking
through the MATLAB documentation, I think I need to use quiver
function.

But in order to use the quiver function, I need to call the meshgrid
function to generate some sort of matrix. After looking at the help on
meshgrid, I'm not sure what it does.

The following comes from the documentation:
"[X,Y] = MESHGRID(x,y) transforms the domain specified by vectors
    x and y into arrays X and Y that can be used for the evaluation
    of functions of two variables and 3-D surface plots.
    The rows of the output array X are copies of the vector x and
    the columns of the output array Y are copies of the vector y."

Can some kind person explain to me what that means?

Subject: Help: What is meshgrid used for?

From: tpl@eng.cam.ac.uk (Tim Love)

Date: 24 Mar, 2004 16:53:59

Message: 2 of 5

wjgoh@gdnmail.net (Wee Jin Goh) writes:


>But in order to use the quiver function, I need to call the meshgrid
>function to generate some sort of matrix. After looking at the help on
>meshgrid, I'm not sure what it does.

>The following comes from the documentation:
>"[X,Y] = MESHGRID(x,y) transforms the domain specified by vectors
> x and y into arrays X and Y that can be used for the evaluation
> of functions of two variables and 3-D surface plots.
> The rows of the output array X are copies of the vector x and
> the columns of the output array Y are copies of the vector y."

>Can some kind person explain to me what that means?
Just try a simple example. Typing
    [X Y] = meshgrid(1:3, 4:5)
shows you the resulting arrays. X contains the x value of each point in
the plane, and Y contains the y values. Matlab likes the coords to be
in this form. You can then do
    Z=X.*Y
to calculate Z values for each point, and then
    surf(X,Y,Z)
 

Subject: Help: What is meshgrid used for?

From: us

Date: 24 Mar, 2004 13:47:12

Message: 3 of 5

> wjgoh@gdnmail.net (Wee Jin Goh):
<SNIP intro...
> After looking at the help on meshgrid, I'm not sure what it does.

Tim Love replies:
> Just try a simple example...
<SNIP nice example

a sad day! CSSM now has to come down to show its children the
quintessentials and very power of ML: play.
just go ahead and type something into the command window, just
anything, be playful, frolic on the keyboard, i swear your computer
isn't going to bite you or explode into your face.

us

Subject: Help: What is meshgrid used for?

From: wjgoh@gdnmail.net (Wee Jin Goh)

Date: 25 Mar, 2004 14:09:21

Message: 4 of 5

us <us@neurol.unizh.ch> wrote in message news:<eed4617.1@webx.raydaftYaTP>...
> > wjgoh@gdnmail.net (Wee Jin Goh):
> <SNIP intro...
> > After looking at the help on meshgrid, I'm not sure what it does.
>
> Tim Love replies:
> > Just try a simple example...
> <SNIP nice example
>
> a sad day! CSSM now has to come down to show its children the
> quintessentials and very power of ML: play.
> just go ahead and type something into the command window, just
> anything, be playful, frolic on the keyboard, i swear your computer
> isn't going to bite you or explode into your face.
>
> us

No, it probably wouldn't explode, but you wouldn't understand what
you're getting either, which is the my case.

Wee Jin

Subject: Help: What is meshgrid used for?

From: wjgoh@gdnmail.net (Wee Jin Goh)

Date: 25 Mar, 2004 14:10:19

Message: 5 of 5

tpl@eng.cam.ac.uk (Tim Love) wrote in message news:<c3sef7$dme$1@pegasus.csx.cam.ac.uk>...
> wjgoh@gdnmail.net (Wee Jin Goh) writes:
>
>
> >But in order to use the quiver function, I need to call the meshgrid
> >function to generate some sort of matrix. After looking at the help on
> >meshgrid, I'm not sure what it does.
>
> >The following comes from the documentation:
> >"[X,Y] = MESHGRID(x,y) transforms the domain specified by vectors
> > x and y into arrays X and Y that can be used for the evaluation
> > of functions of two variables and 3-D surface plots.
> > The rows of the output array X are copies of the vector x and
> > the columns of the output array Y are copies of the vector y."
>
> >Can some kind person explain to me what that means?
> Just try a simple example. Typing
> [X Y] = meshgrid(1:3, 4:5)
> shows you the resulting arrays. X contains the x value of each point in
> the plane, and Y contains the y values. Matlab likes the coords to be
> in this form. You can then do
> Z=X.*Y
> to calculate Z values for each point, and then
> surf(X,Y,Z)

Thanks for the response.

Wee Jin

Tags for this Thread

No tags are associated with 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