Ignoring certain matrix entries with surf plot
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
darova
il 9 Ago 2021
Don't use '==' equal sign for comparing double numbers
ii = abs(MatrixName-0)<0.1; % precision
MatrixName(ii) = NaN;
1 Commento
Jacob Wilson
il 9 Ago 2021
Categorie
Scopri di più su Surface and Mesh Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
