필터 지우기
필터 지우기

How to plot a line of zero value on a surface?

조회 수: 11 (최근 30일)
Ying Wu
Ying Wu 2022년 12월 13일
댓글: Star Strider 2022년 12월 13일
I used surf to generate a 3D surface and see it in 2D view (see below)
The dataset and code are also attached.
X=[0 0.25 0.5 0.75]'; % 4*1 vector
load Y.mat % 36*4 matrix
load Z.mat % 36*4 matrix
figure
set(gcf,'position',[100,100,1000,750]);
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceColor', 'interp');
hold on;
colormap(coolwarm(256)); caxis([-0.35 0.35]); colorbar;
patch([0,0.8,0.8,0],[0.8,0.8,0,0],[0,0,0,0],[1,1,1,1],'FaceAlpha',0.5,'EdgeColor',[0,0,0]);
grid off; view(2);
Now I want to plot the intersection of surface and zero-plane, can anyone help to with that? Thanks!

채택된 답변

Star Strider
Star Strider 2022년 12월 13일
Use contour3 to draw the boundary (here a red line with 'LineWidth',5) —
LD1 = load(websave('Y','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1230092/Y.mat'));
Y = LD1.Amp;
LD2 = load(websave('Z','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1230097/Z.mat'));
Z = LD2.Pnet;
X=(ones(size(Z,1),1)*[0 0.25 0.5 0.75]);
% 4*1 vector
% load Y.mat % 36*4 matrix
% load Z.mat % 36*4 matrix
figure
set(gcf,'position',[100,100,1000,750]);
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceColor', 'interp');
hold on;
colormap(turbo(256)); caxis([-0.35 0.35]); colorbar;
patch([0,0.8,0.8,0],[0.8,0.8,0,0],[0,0,0,0],[1,1,1,1],'FaceAlpha',0.5,'EdgeColor',[0,0,0]);
contour3(X, Y, Z, [0 0], '-r', 'LineWidth',5)
grid off
view(-160,30)
% view(2);
The plane at ‘Z=0’ partially obscures the line.
.
  댓글 수: 4
Ying Wu
Ying Wu 2022년 12월 13일
Thanks for detailed reply!
Star Strider
Star Strider 2022년 12월 13일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by