MATLAB: How to get the cross-sectional area of a PDE model

cross-sectionMATLABmeshpde

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?

Best Answer

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