How do I plot the contour of a surface at a specific height?

I have a surface that has been defined using surf(S) where S is simply a 25x25 matrix, i.e. the height of the surface at a particular point is represented by the elements in S.
Now, what I want to have is the curve on the x-y plane representing the points of S that are at height 3514. So I saw how I could add a plane at height 3514 and find the intersection of the plane and interpolate, but this seemed quite involved and I figured maybe there's an easier way? For example, surfc plots contours on the x-y plane of the 3D plot for you. Would there perhaps be a way to specifically determine at what height you wanted the contour and then extract the vector representing that curve and plot it separately on a 2D plot?
Thanks!

 採用された回答

Mike Garrity
Mike Garrity 2014 年 12 月 8 日

3 投票

I'm not sure I follow, do you just mean something like this?
z=peaks;
surf(peaks)
hold on
contour3(z,'LevelList',2,'Color','red')

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 12 月 7 日

1 投票

You could just do
thisLevel = s > 25;
imshow(thisLevel); % In IPT or base MATLAB after R2014b
If you have the Image Processing Toolbox, you could then do
boundaries = bwboundaries(thisLevel);
to get a list of (x,y) coordinates of the outer boundary of that slice.
Rafael
Rafael 2014 年 12 月 10 日

0 投票

Great answers both, basically the exact two things I was looking for. Thanks! :)

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

質問済み:

2014 年 12 月 7 日

回答済み:

2014 年 12 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by