What about this?
clc,clear
r = 0:0.1:5;
t = linspace(0,2*pi,30);
[T,R] = meshgrid(t,r);
Z = 5*sin(R)./R;
[X,Y] = pol2cart(T,R);
x = [1 3 0.7];
y = [0.2 0.3 3];
z = [1 1.2 1];
ix = convhull(X(:),Y(:));
x1 = X(ix(1:end-2));
y1 = Y(ix(1:end-2));
gd1 = [2; length(x1); x1(:); y1(:)];
gd2 = gd1;
gd2(1:2+2*length(x)) = [2; length(x); x(:); y(:)];
dl = decsg([gd1 gd2],'P1-P2',char('P1','P2')');
[p,e,t] = initmesh(dl,'hmax',0.5);
F = scatteredInterpolant(X(:),Y(:),Z(:));
zz = F(p(1,:),p(2,:));
fv.vertices = [p;zz]';
fv.faces = t(1:3,:)';
cla
patch(fv,'facecolor','r')
patch(x,y,z,'g')
view(150,45)
axis vis3d
If you have boundary intstead of convhull ix = convhull(X(:),Y(:));
Best Answer