Effacer les filtres
Effacer les filtres

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

20 vues (au cours des 30 derniers jours)
Ying Wu
Ying Wu le 13 Déc 2022
Commenté : Star Strider le 13 Déc 2022
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!

Réponse acceptée

Star Strider
Star Strider le 13 Déc 2022
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 commentaires
Ying Wu
Ying Wu le 13 Déc 2022
Thanks for detailed reply!
Star Strider
Star Strider le 13 Déc 2022
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by