How to slice an outer surface plot to reveal an inner surface plot in MATLAB?

1 次查看(过去 30 天)
I have the following sample code which creates two 3D plots on the same axes and which overlay each other:
[X,Y,Z] = peaks(75);
[Xa,Ya,Za] = peaks(50);
figure
surf(X,Y,Z)
colormap(spring)
shading(interp)
hold on
surf(Xa,Ya,Za)
colormap(winter)
shading(interp)
hold off
grid off
xlabel('X')
ylabel('Y')
zlabel('Z')
title('Surface Plot')
I wish to remove a portion of the first outer plot [surf(X,Y,Z)] to reveal the second inner plot [surf(Xa,Ya,Za)]. The cross-section of the segment to be removed should be a quadrant of the first plot in the XY plane.
Please advise on how this can be done in MATLAB?
Thanks!

采纳的回答

Bruno Luong
Bruno Luong 2022-4-9
Use NaN to remove points you don't want to see, adapt to your need
[X,Y,Z] = peaks(75);
[Xa,Ya,Za] = peaks(50);
Z(X<0 & Y<0) = NaN;
Za = -1-0.5*Za;
%Za(Xa<0 & Ya<0) = NaN;
figure
surf(X,Y,Z,'FaceColor','b')
hold on
surf(Xa,Ya,Za,'FaceColor','y')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by