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:
plot a 3D table

Subject: plot a 3D table

From: Jose

Date: 17 May, 2010 14:35:04

Message: 1 of 5

Hello to everyone, can you help me with it:

I would like to plot a table x, y with the z values, where the square x=0.25 y = 0.25 correspond to z = 95. Thanks in advance.

x=[0.25 0.5 0.75 1]

y=[0.25 0.5 0.75 1]

z =

    27 89 79 43
    95 35 72 46
    74 55 30 41
    37 40 39 3

Subject: plot a 3D table

From: Walter Roberson

Date: 17 May, 2010 14:55:02

Message: 2 of 5

Jose wrote:

> I would like to plot a table x, y with the z values, where the square
> x=0.25 y = 0.25 correspond to z = 95. Thanks in advance.
>
> x=[0.25 0.5 0.75 1]
>
> y=[0.25 0.5 0.75 1]
>
> z =
>
> 27 89 79 43
> 95 35 72 46
> 74 55 30 41
> 37 40 39 3

surf(x,y,z)

or use bar3() or pcolor()

Subject: plot a 3D table

From: Roger Stafford

Date: 17 May, 2010 15:14:20

Message: 3 of 5

"Jose " <jose.l.vega@gmail.com> wrote in message <hsrk6o$b1f$1@fred.mathworks.com>...
> Hello to everyone, can you help me with it:
>
> I would like to plot a table x, y with the z values, where the square x=0.25 y = 0.25 correspond to z = 95. Thanks in advance.
>
> x=[0.25 0.5 0.75 1]
>
> y=[0.25 0.5 0.75 1]
>
> z =
>
> 27 89 79 43
> 95 35 72 46
> 74 55 30 41
> 37 40 39 3
- - - - - - - -
 You first need to make meshes of x and y. Use

 [X,Y] = meshgrid(x,y);

if x is understood to vary along the rows of z, or

 [Y,X] = meshgrid(y,x);

if x varies along the columns of z. Then do

 surf(X,Y,z)

Roger Stafford

Subject: plot a 3D table

From: Walter Roberson

Date: 17 May, 2010 15:45:44

Message: 4 of 5

Roger Stafford wrote:
> "Jose " <jose.l.vega@gmail.com> wrote in message

>> x=[0.25 0.5 0.75 1]
>> y=[0.25 0.5 0.75 1]

> You first need to make meshes of x and y. Use

> if x varies along the columns of z. Then do
> surf(X,Y,z)

surf is happy to accept vectors for x and y.

     SURF(x,y,Z) and SURF(x,y,Z,C), with two vector arguments replacing
     the first two matrix arguments, must have length(x) = n and
     length(y) = m where [m,n] = size(Z). In this case, the vertices
     of the surface patches are the triples (x(j), y(i), Z(i,j)).
     Note that x corresponds to the columns of Z and y corresponds to
     the rows.

Subject: plot a 3D table

From: Roger Stafford

Date: 17 May, 2010 15:58:04

Message: 5 of 5

Walter Roberson <roberson@hushmail.com> wrote in message <IwdIn.14229$0M5.11061@newsfe07.iad>...
> surf is happy to accept vectors for x and y.

  You're right, Walter. I forgot about that provision.

Roger Stafford

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