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

28 visualizzazioni (ultimi 30 giorni)
I want to create a SURF or MESH plot but would like the surface to have empty regions or holes in specific places.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 24 Mag 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.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by