Contour plot - how to show contours of irregular body in XY plane?

3 views (last 30 days)
Hi all
I use contour(X,Y,Z,n) function and it works fine. However, sometimes I would like to show only one part of the contours which are in top view (X-Y plane) within body of irregular shape. Something similar like "inpolygon".
Is anybody having an idea how to show only contours within selected area?
Thanks, Janez

Accepted Answer

Sean de Wolski
Sean de Wolski on 12 Apr 2013
You could replace the values that you don't want with NaNs. For example:
[x,y,z] = peaks;
subplot(121)
contourf(x,y,z)
z(abs(z)<0.5) = nan;
subplot(122)
contourf(x,y,z)

More Answers (0)

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!