Cross-sectional area of a cone(ish)

4 visualizzazioni (ultimi 30 giorni)
jlt199
jlt199 il 31 Ago 2016
Risposto: jlt199 il 9 Set 2016
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?

Risposta accettata

John D'Errico
John D'Errico il 31 Ago 2016
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 Commenti
jlt199
jlt199 il 9 Set 2016
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 il 9 Set 2016
Ok, I've figured out the structure of C now. Now I just need to figure out what to do with it...

Accedi per commentare.

Più risposte (2)

Chad Greene
Chad Greene il 31 Ago 2016
Modificato: Chad Greene il 31 Ago 2016
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 Commenti
Sean de Wolski
Sean de Wolski il 31 Ago 2016
How is C2xyz different than contourc?
Chad Greene
Chad Greene il 9 Set 2016
Hey Sean, the C2xyz function simply converts the difficult-to-interpret C matrix into more intuitive x and y values.

Accedi per commentare.


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

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by