contour grid points

조회 수: 12 (최근 30일)
elalexcs K
elalexcs K 2011년 8월 3일
Does any one knows how to retrieve the exact grid points of a specific contour when using contour or contourf function. I want to retrive the grid points that matlab uses to plot a specific value of a contour line.
thank you
  댓글 수: 1
elalexcs K
elalexcs K 2011년 8월 4일
Man you are a genious!!
Just what I needed.
thanks a lot appreciate it

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2011년 8월 3일
contour() and contourf() are almost identical internally. They return a single hggroup object, and that hggroup object have a bunch of Children. Each of the Children is a patch object for a different contour level, one patch object per level, with embedded NaN in the coordinates where needed to jump from one place to another in the drawing.
The code that builds the contours sets the Z coordinates to the level of the contour heights, but then one of the last things that contour / contourf does is reset those coordinates to 0. Fortunately, each patch object has a UserData property that is used to store the contour level that it was for.
Soooo...
chand = contour(....);
cpatches = get(chand, 'Children');
for K = 1:length(cpatches)
xcoord{K} = get(cpatches(K),'XData');
ycoord{K} = get(cpatches(K),'YData');
zcoord{K} = get(cpatches(K),'UserData');
end
Warning: for any contour that is moderately complex, the list of coordinates will be pretty messy, lots of ins-and-outs.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by