필터 지우기
필터 지우기

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

조회 수: 5 (최근 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