Ignoring certain matrix entries with surf plot
Afficher commentaires plus anciens
Hi!
I am attempting to plot some data in a matrix using the surf command. Every nonzero elements happens to be padded by zero elements (i.e. the elements
and
are zero for every nonzero
. I'd like to plot a surface of the nonzero elements only, but I have tried a number of things and have not been able to figure out how to exclude the zero elements. For instance, I tried something like
MatrixName(MatrixName==0)=NaN;
Surf(x,y,MatrixName);
but this method ignores all patches contiaining the zero element points and, due to the nature of my matrix, all surface patches are ignored.
Does anyone know how to request that matlab simply ignore zero elements in generating a surface plot?
Sincerely,
Jacob
Réponse acceptée
Plus de réponses (1)
darova
le 9 Août 2021
Don't use '==' equal sign for comparing double numbers
ii = abs(MatrixName-0)<0.1; % precision
MatrixName(ii) = NaN;
1 commentaire
Jacob Wilson
le 9 Août 2021
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
