How to get the cross-sectional area of a PDE model
11 次查看(过去 30 天)
显示 更早的评论
Now I have a 3D model of a rebar as a .stl file and I want to calculate the cross-sectional area of this rebar at different places. My point is to calculate the area so the contour or slice function doesn't work for me.
I have imported this model to MATLAB as a PDEModel. But when I searched for the cross-sectional area of a PDEModel, I just got how to plot the PDE solution.
Then I used the generateMesh function to get a FEMesh. I think maybe the Surface Intersection function can do it but I don't know how to build a surface from the FEMesh.
So is there any way I can do this?
2 个评论
采纳的回答
darova
2020-5-18
See this solution
f1 = stlread('Cylinder.stl');
[y,z] = meshgrid(-2:2); % meshgrid for plane
h = surf(y*0+2,y,z); % crossection plane
f2 = surf2patch(h,'triangles'); % convert to patch
f2.facecolor= 'r';
patch(f1,'facecolor','y') % display cylinder
patch(f2) % display crossection plane
[~,ff] = SurfaceIntersection(f1,f2);% find crossection line
ff = rmfield(ff,'edges'); % remove edges
patch(ff,'linew',2) % display crossection line
alpha(0.3) % make surfaces transparent
axis vis3d equal

13 个评论
darova
2021-2-9
- Do you know why the function is throwing an error when I place the intersection plane at 0 or 50 (lower and upper limit of the cone) ?
I believe the answer is:
Error: in IntersectionPolygon: key is out of bound
Try
h2 = surf(y,z,z*0+50-0.01);
h2 = surf(y,z,z*0+0.01);
- This is what my crosse sections look like. Is there a command that fills the cross section with a certain color?
Sure, use patch or fill
Matt
2023-4-24
Hey I'm having a similar issue with this method, I can't find why it doesn't work on my side when trying to "convert" the points/Clist to vertices and faces.
I run the following code :
f1 = stlread('OBJECT.stl');
[y,z] = meshgrid(-20:20);
h = surf(y*0+20,y,z);
f2 = surf2patch(h,'triangles');
f2.facecolor= 'r';
f1.vertices = f1.Points;
f1.faces = f1.ConnectivityList;
f1 = rmfield(f1,'Points','ConnectivityList');
patch(f1,'FaceColor','y')
patch(f2)
but I get this error : Unrecognized property 'vertices' for class 'triangulation'.
and also it seems to Matlab that I don't have enough arguments for patch(f1,'FaceColor','y').
Would appreciate any help !
~Matt
更多回答(1 个)
DGM
2025-3-29
See also this answer using the same FEX tool. This should solve a few of the issues with SurfaceIntersection(). The setup of patch objects is handled internally by the given function, so that solves some usage issues or at least serves as an example. The conversion of unsorted edge lists into sane closed polygons is also handled.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geometry and Mesh 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




