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:
surf plot

Subject: surf plot

From: Samyuktha

Date: 26 Jul, 2013 05:17:12

Message: 1 of 3

Hi all....

I have the matrices x,y and z each of size 30x1. x & y are the X,Y coordinates and z represents the height of the coordinate at that point. I would like do something like a surf plot so that at the respective coordinate i get a surf with the corresponding height)

I have tried something like this.

[x,y] = meshgrid(-3:1/4.9:3);
z = p1; //here z is converted from 30x1 to 30x30 because only then peaks can be applied
z = peaks(z);
surfl(x,y,z);
shading interp
colormap(jet);
axis([-3 3 -3 3 0 2])

Here I have kept the scale fixed as -3 to +3 but the difficulty is I am not able to figure out the 30 coordinates.

My actual x,y, z looks similar to this.

x = [180; 270; 120; 160; 225; 290; 335; 100; 150; 225; 305; 355; 95; 145; 225; 315; 360; 110; 150; 225; 305; 345; 125; 165; 225; 290; 330; 175; 225; 280];
y = [45; 45; 90; 105; 105; 105; 90; 145; 155; 155; 155; 145; 200; 200; 200; 200; 200; 260; 250; 250; 250 ; 260; 320; 310; 310; 310; 320; 360; 360; 360];
z = [1; 5; 6; 19; 18; 16; 16; 4; 16; 19; 23; 20; 6; 18; 21; 21; 13; 12; 12; 20; 21; 20; 11; 8; 23; 18; 17; 19; 20; 1];

And I would like to plot the x&y and then do the surf plot.

Thanks for the help.

Subject: surf plot

From: Chris

Date: 26 Jul, 2013 13:58:16

Message: 2 of 3

Some details in your question are unclear:
(1) what is p1, how is the initial vector z used to generate p1?
(2) what 30 coordinates are you referring to?

Subject: surf plot

From: Steven_Lord

Date: 26 Jul, 2013 14:28:22

Message: 3 of 3



"Samyuktha " <chweetheart0707@gmail.com> wrote in message
news:kst0oo$77f$1@newscl01ah.mathworks.com...
> Hi all....
>
> I have the matrices x,y and z each of size 30x1. x & y are the X,Y
> coordinates and z represents the height of the coordinate at that point. I
> would like do something like a surf plot so that at the respective
> coordinate i get a surf with the corresponding height)
>
> I have tried something like this.
>
> [x,y] = meshgrid(-3:1/4.9:3);
> z = p1; //here z is converted from 30x1 to 30x30 because only then peaks
> can be applied
> z = peaks(z);

This is almost certainly NOT doing what you want.

> surfl(x,y,z);
> shading interp
> colormap(jet);
> axis([-3 3 -3 3 0 2])
>
> Here I have kept the scale fixed as -3 to +3 but the difficulty is I am
> not able to figure out the 30 coordinates.

Use GRIDDATA to convert your scattered data into gridded data. SURF(L)
understands gridded data, not scattered data.

Alternately you could try to triangulate your data (DelaunayTriangulation)
and then use TRISURF.

http://www.mathworks.com/help/matlab/delaunay-triangulation.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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