Why does CONTOURF return NaN for some output values in MATLAB 7.7 (R2008b)?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 7 Jan 2010
Modifié(e) : MathWorks Support Team
le 27 Jan 2017
When I run the following code with CONTOURF, I receive NaN for some output values.
[C,h] = contourf(peaks(20),10);
find(isnan(C)) % Displays the indices of NaNs in C.
Réponse acceptée
MathWorks Support Team
le 27 Jan 2017
This change has been incorporated into the documentation in Release 2009b (R2009b). For previous releases, read below for any additional information:
NaN values in the output of CONTOURF exist for degenerate lines, and contours that hit the edges of the axes and which CONTOURF forces to close.
The CONTOURF algorithm takes the original z matrix, then pads by wrapping an extra row on the top and bottom and an extra column on the left and right. These extra rows and columns are assigned significantly low values in order to enable interpolation at the boundary. Then the contour segments for each of the contour levels are calculated.
The CONTOURF algorithm postprocesses the resulting contourmatrix, and replaces the long contiguous boundary segments with NaNs so that downstream MATLAB functions handle rendering and other computation correctly
The contour matrix thus generated is parsed according to the documentation for CONTOUR/CONTOURF, i.e., each contiguous drawing segment contains the value of the contour, the number of x,y drawing pairs, and the pairs themselves. The result does not contain NaNs, but the result contains long contiguous segments that wrap around the outer boundary of the original z matrix. The CONTOURF algorithm then postprocesses the contour matrix, and replaces the long contiguous boundary segments with NaNs so that downstream MATLAB functions handle rendering and other computation correctly.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!