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

Subject: contour

From: mona

Date: 23 Dec, 2009 19:18:05

Message: 1 of 5

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.

         0 , 0 , 0.0752
         0 , 0.0100 , 0.0751
         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.
Can anyone tell me the required steps to do that.


mona

Subject: contour

From: ImageAnalyst

Date: 23 Dec, 2009 19:24:59

Message: 2 of 5

mona:
You need to get this data into a 2D numerical array, where for a
particular x,y coordinate (index) you have a value (your z value).
Take a look at interp2(). You can set up a regular sampling distance,
like very 0.001 is a new index. Then, you'll call interp2() to fill
in the missing values at the indexes where you don't have any date.
Then you can call contour.

Subject: contour

From: John D'Errico

Date: 23 Dec, 2009 19:26:06

Message: 3 of 5

"mona " <iee2006@yahoo.com> wrote in message <hgtqdd$l4e$1@fred.mathworks.com>...
> 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.
>
> 0 , 0 , 0.0752
> 0 , 0.0100 , 0.0751
> 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.
> Can anyone tell me the required steps to do that.

download tricontour from the file exchange

John

Subject: contour

From: Nathan

Date: 23 Dec, 2009 19:26:12

Message: 4 of 5

On Dec 23, 11:18 am, "mona " <iee2...@yahoo.com> wrote:
> 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.
>
>          0   ,      0   , 0.0752
>          0   , 0.0100  ,  0.0751
>          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.
> Can anyone tell me the required steps to do that.
>
> mona

Assume A is your matrix containing the given data.

contour(A) %contour map of A
contourf(A) %filled contour map of A

Is that what you want?

-Nathan

Subject: contour

From: someone

Date: 23 Dec, 2009 21:07:03

Message: 5 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <c94a1684-1174-41d3-bffa-7d34406bc71b@o28g2000yqh.googlegroups.com>...
> mona:
> You need to get this data into a 2D numerical array, where for a
> particular x,y coordinate (index) you have a value (your z value).
> Take a look at interp2(). You can set up a regular sampling distance,
> like very 0.001 is a new index. Then, you'll call interp2() to fill
> in the missing values at the indexes where you don't have any date.
> Then you can call contour.

% Aside from what others have suggested,
% if you need to get the data into a MATLAB array, type

doc csvread

% in the MATLAB command window.

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