Borrar filtros
Borrar filtros

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

11 visualizaciones (últimos 30 días)
Ying Wu
Ying Wu el 13 de Dic. de 2022
Comentada: Star Strider el 13 de Dic. de 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!

Respuesta aceptada

Star Strider
Star Strider el 13 de Dic. de 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 comentarios
Ying Wu
Ying Wu el 13 de Dic. de 2022
Thanks for detailed reply!
Star Strider
Star Strider el 13 de Dic. de 2022
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by