MATLAB: Draw partial spheroid include a spheroid

1/8meshslidesphere

I want to draw 1/8 spheroid include a small spheroid and output the geometry for mesh. But my current coding always have discontinue in the cutting plan.
Can anyone help provide a idea of cutting the spheroid in 1/8 not for showing but get the data.

Best Answer

The code bellow us this FEX to generate mesh points.
% radius of the inner/outer spherical parts
r1 = 1;
r2 = 2;
n = 20; % discretization parameters of spherical parts
W = allVL1(3, n); % FEX file
% Connectivity
XY = W*[0 1 0;
0 0 1].';
F=delaunay(XY);
% Points in S2
Tri3 = eye(3);
W = W/n;
XYZ = W*Tri3';
XYZ = XYZ ./ sqrt(sum(XYZ.^2,2));
% inner/outer sphericals
XYZ1 = XYZ*r1;
XYZ2 = XYZ*r2;
% TRUE for points on the boundary
ibdr = W==0;
close all
patcharg = {'FaceColor', 'g', 'FaceAlpha', 0.5};
patch('Faces', F, 'Vertices', XYZ1, patcharg{:});
patch('Faces', F, 'Vertices', XYZ2, patcharg{:});
for k=1:3
XYZk = [XYZ1(ibdr(:,k),:); flipud(XYZ2(ibdr(:,k),:))];
% You are free to mesh XYZk, I leave it as polygonal shape (quarter of a rings)
patch('XData', XYZk(:,1), 'YData', XYZk(:,2), 'ZData', XYZk(:,3), patcharg{:});
end
view(3)
axis equal