How to plot a line of zero value on a surface?
조회 수: 19 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
Star Strider
2022년 12월 13일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!