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:
? cal the length and area of contours

Subject: ? cal the length and area of contours

From: Cheng Cosine

Date: 18 May, 2013 10:36:24

Message: 1 of 5

Hi:

 One can use contour() to plot contours. But how does one calculate the
length and area of a contour?

 Thanks,

Subject: ? cal the length and area of contours

From: Nasser M. Abbasi

Date: 18 May, 2013 10:54:46

Message: 2 of 5

On 5/18/2013 5:36 AM, Cheng Cosine wrote:
> Hi:
>
> One can use contour() to plot contours. But how does one calculate the
> length and area of a contour?
>
> Thanks,
>


 From help:

---------------
load penny;
figure;
contour(flipud(P));
axis square;
------------------

So, looking at the above. what length and what area are you
refering to?

one contour line represent the same value in the data.

So, I am not even sure what measure of length you
are taking about, and what area you want, since
these lines can all change depending on how many
contour lines you want. If you ask for 2 lines,
you'll get different shapes.

May be if you explain what is it you are trying to do,
someone might have better suggestion.

--Nasser

Subject: ? cal the length and area of contours

From: Bruno Luong

Date: 18 May, 2013 12:09:13

Message: 3 of 5

Cheng Cosine <asecant@gmail.com> wrote in message <a100acf9-b4a8-47b8-9b2d-fd49d3f0af2c@googlegroups.com>...
> Hi:
>
> One can use contour() to plot contours. But how does one calculate the
> length and area of a contour?

Use syntax [c h] = contour(...) to retrieve the contour polygons. Then you can compute the length by summing the lengths of the edges, and use polyarea() to compute the surface.

Bruno

Subject: ? cal the length and area of contours

From: Cheng Cosine

Date: 18 May, 2013 13:03:26

Message: 4 of 5

Nasser M. Abbasi於 2013年5月18日星期六UTC+8下午6時54分46秒寫道:
> On 5/18/2013 5:36 AM, Cheng Cosine wrote:
>
> > Hi:
>
> >
>
> > One can use contour() to plot contours. But how does one calculate the
>
> > length and area of a contour?
>
> >
>
> > Thanks,
>
> >
>
>
>
>
>
> From help:
>
>
>
> ---------------
>
> load penny;
>
> figure;
>
> contour(flipud(P));
>
> axis square;
>
> ------------------
>
>
>
> So, looking at the above. what length and what area are you
>
> refering to?
>
>
>
> one contour line represent the same value in the data.
>
>
>
> So, I am not even sure what measure of length you
>
> are taking about, and what area you want, since
>
> these lines can all change depending on how many
>
> contour lines you want. If you ask for 2 lines,
>
> you'll get different shapes.
>
>
>
> May be if you explain what is it you are trying to do,
>
> someone might have better suggestion.
>
>
>
> --Nasser

The data file you referred to is too complicated. A single value corresponds
to more than one contours.

Suppose we have a "clean" circular disk and on it we have different contours.

A single value corresponds to a single contour. To be specific, those contours

are closed and concentric circular curves.

 If we know the radius of a contour, we can compute its circular length as 2*pi*r and area as pi*( r_outer^2-r_inner^2 ).

 What I aksed for were to compute the perimeter and area when the target contour is not a simply cicle or ellipse.

Subject: ? cal the length and area of contours

From: TideMan

Date: 18 May, 2013 21:10:57

Message: 5 of 5

On Saturday, May 18, 2013 10:36:24 PM UTC+12, Cheng Cosine wrote:
> Hi:
>
>
>
> One can use contour() to plot contours. But how does one calculate the
>
> length and area of a contour?
>
>
>
> Thanks,

help contourc
Look at the last paragraph. It tells you how to extract the x,y of the contour lines, whence you can calculate the length and area of each contour.

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