Why do contour plots display values at discontinuities using MATLAB 7.2 (R2006a)?
6 views (last 30 days)
Show older comments
When I create a contour plot of a function which has a discontinuity, MATLAB displays contour lines at the point of the discontinuity as well.
Consider the following example:
[x,y] = meshgrid(-2.05:.1:2.05, -2.05:.1:2.05);
contour(x,y,atan2(y,x))
Accepted Answer
MathWorks Support Team
on 20 Jun 2011
This change has been incorporated into the documentation in Release 2011a (R2011a). For previous releases, read below for any additional information:
CONTOUR cannot tell that there is a discontinuity in your data. You need to put in NaN values along the discontinuity to resolve this issue. For example, you might want to put NaN's along the line y=0 for x<0 in this example:
[x,y] = meshgrid(-2.05:.1:2.05,[ -2.05:.1:-0.05,0,0.05:.1:2.05]);
y(y==0 & x<0) = NaN; % Requires MATLAB 5
contour(x,y,atan2(y,x))
0 Comments
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!