nx = 100;
px = linspace(1,50,nx);
pyi = 5+sin(0.8*px);
py = 6+sin(0.8*px);
n=25;
t=(0:n)'*0.5*pi/n;
XYZI = cat(3,ones(n+1,1)*px, cos(t)*pyi, sin(t)*pyi);
XYZE = cat(3,ones(n+1,1)*px, cos(t)*py, sin(t)*py);
isbdri = false(size(XYZI,1),size(XYZI,2));
isbdri([1 end],:) = true;
isbdri(:,[1 end]) = true;
isbdre = false(size(XYZE,1),size(XYZE,2));
isbdre([1 end],:) = true;
isbdre(:,[1 end]) = true;
XYZI = reshape(XYZI,[],3);
n = size(XYZI,1);
XYZE = reshape(XYZE,[],3);
XYZ = [XYZI; XYZE];
isbdr = [isbdri; isbdre];
T = delaunay(XYZ);
b = T<=n;
keep = any(b,2) & any(~b,2) & sum(isbdr(T),2)<=3;
T = T(keep,:);
close all
tetramesh(T,XYZ,'FaceColor','g')
Best Answer