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:
contour

Subject: contour

From: mona

Date: 26 Dec, 2009 22:24:03

Message: 1 of 2

hello;

I need to plot contour using existing x,y,z data.

Only thing I have is following x,y,z data as a text file.

         x y z

         0 , 0 , 0.0752
         0 , 0.0200 , 0.0752
         0 , 0.0300, 0.0749
    0.0100 , 0 , 0.0744
    0.0100 , 0.0100 , 0.0741
    0.0200 , 0 , 0.0741
    0.0200 , 0.0200 , 0.0748
    0.0300 , 0 , 0.0747
    0.0300 ,0.0300, 0.0743
    0.0410 , 0 , 0.0736
    0.0410 , 0.0300 , 0.0738
    0.0500 , 0 , 0.0732
    0.0600 , 0 , 0.0728
         0 , 0.1130 , 0
    0.0410 , 0.0410 , 0
    0.0650 , 0 , 0
    0.0700 , 0 ,-0.0302
    0.0800 , 0 , -0.0304
    0.0900 , 0 , -0.0306
    0.0410 , 0.0500 , -0.0330
    0.0410 , 0.0600 , -0.0330
    0.0500 , 0.0500 , -0.0331
    0.0500 , 0.0600 , -0.0331
    0.0500 , 0.0500 , -0.0332

From help menu, I found that there is a command called contour to perform this task.


 But I cannot understand how to do it from my existing data.


 I aim to plot the area where z<0 and the area where z>0 ; for this I thihk that good to use contour.;
this is what I did

xlin=linspace(min(x),max(x),33);
ylin=linspace(min(y),max(y),33);

[X,Y]=meshgrid(xlin,ylin)
Z=griddata(x,y,z,X,Y)

[c,h]=contourf(X,Y,Z,[0 0 ]);

is that ok?

thanks







----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Subject: contour

From: Rune Allnor

Date: 27 Dec, 2009 06:32:15

Message: 2 of 2

On 26 Des, 23:24, "mona " <iee2...@yahoo.com> wrote:
> hello;
>
> I need to plot  contour using existing x,y,z data.
>
> Only thing I have is following x,y,z data as a text file.
>
>          x          y        z
...
> From help menu, I found that there is a command called contour  to perform this task.
>
>  But I cannot understand how to do it from my existing data.

CONTOUR and friends can not handle these kinds of data
(unless something has changed very recently; I am using
a quite old version of matlab). These functions require
the z data to be presented as a matrix of data sampled
on a regular (x,y) grid, whereas your data are irregularly
sampled.

The way to do this is to first build a Delaunay triangulation
from the data, and then contour the resulting surface.

Again, my version of matlab is old, and I know there has
been a lot of modifications to the triangulation functions
in matlab recently. With a bit of luck, the most recent
version of matlab might provide a contouring function
for triangulations. If not, there might be such a function
available from the FEX.

Rune

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