How do I make a mesh or surface plot that is clear in certain places?

26 vues (au cours des 30 derniers jours)
I want to create a SURF or MESH plot but would like the surface to have empty regions or holes in specific places.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 24 Mai 2013
If the surface or mesh data has a NaN (not-a-number) in it, then the location of the NaN will be blank (just as NaNs in 2-d plots leave blanks). The example below illustrates using NaNs to make certain parts of a plot transparent.
%Generate a SURF plot with peaks data
z = peaks;
surf(z)
%Change peaks data so that a portion of that matix is made up of NaNs
m = z;
m(15:30,15:30) = nan;
%Plot the new matrix, m where the x and y information consisting of NaNs
%represents a hole in the SURF plot
figure;
surf(m)
As of MATLAB 6.0 (R12) you can use transparency to set a face to be transparent.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by