フィルターのクリア

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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by