Ignoring certain matrix entries with surf plot
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
darova
am 9 Aug. 2021
Don't use '==' equal sign for comparing double numbers
ii = abs(MatrixName-0)<0.1; % precision
MatrixName(ii) = NaN;
1 Kommentar
Jacob Wilson
am 9 Aug. 2021
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
