Cross-sectional area of a cone(ish)

5 ビュー (過去 30 日間)
jlt199
jlt199 2016 年 8 月 31 日
回答済み: jlt199 2016 年 9 月 9 日
Morning all,
I have a surface that looks something like a lopsided squished cone, hollow in the middle.
I would like to take the cross-sectional area at different heights, but I need some help. I'm sure it shouldn't be too difficult but I can't figure it out today. I can use the countour function to plot the contours at different heights, but not find the area of the cross-section.
Can anyone help me please?

採用された回答

John D'Errico
John D'Errico 2016 年 8 月 31 日
And polyarea won't suffice to compute the area of a polygon? It should.
Just generate the contours as desired. Then use polyarea. Easy.
  6 件のコメント
jlt199
jlt199 2016 年 9 月 9 日
Thanks for your help John, I have just got back to this problem after having to leave it to write reports :(
I was as surprised by the level of noise as you, it's only in about 5 of about several hundred surfaces, so I missed it originally.
I'm having a hard time working out the structure of the matrix C which is output from the contour3 function, I have tried looking at the code for contour3, but really didn't understand what was going on. Can anyone help me with this? I would like to isolate polygons as suggested, but I can't understand the data structure.
Another thought I had was to just send the portion of the surface that contains the "horn" to the contour3 function, but I can't think how to do that either.
If anyone can help with either of these two problems I would be very grateful.
This is the surface I am currently working with:
Many thanks
jlt199
jlt199 2016 年 9 月 9 日
Ok, I've figured out the structure of C now. Now I just need to figure out what to do with it...

サインインしてコメントする。

その他の回答 (2 件)

Chad Greene
Chad Greene 2016 年 8 月 31 日
編集済み: Chad Greene 2016 年 8 月 31 日
I'd use my C2xyz function which is on File Exchange to easily get the x,y values of a contour line. Below I'm using the built-in peaks data as an example dataset and getting the area of the polygon bounded by the z=6 line.
[X,Y,Z] = peaks(1000);
pcolor(X,Y,Z);
shading interp
colorbar
zval = 6;
hold on
C = contour(X,Y,Z,zval*[1 1],'k');
[x,y,z] = C2xyz(C);
A = polyarea(x{1},y{1})
A =
0.6661
  2 件のコメント
Sean de Wolski
Sean de Wolski 2016 年 8 月 31 日
How is C2xyz different than contourc?
Chad Greene
Chad Greene 2016 年 9 月 9 日
Hey Sean, the C2xyz function simply converts the difficult-to-interpret C matrix into more intuitive x and y values.

サインインしてコメントする。


jlt199
jlt199 2016 年 9 月 9 日
Thanks, I've managed to get it working in most cases. Except where the noise gets horrendous.
Many thanks for your time

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by