How to slice an outer surface plot to reveal an inner surface plot in MATLAB?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shiraz Kaderuppan
le 9 Avr 2022
Commenté : Shiraz Kaderuppan
le 9 Avr 2022
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!
0 commentaires
Réponse acceptée
Bruno Luong
le 9 Avr 2022
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')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!