How to get coordinates for a specific contour line?

조회 수: 23 (최근 30일)
Sk Zeeshan Ali
Sk Zeeshan Ali 2020년 1월 20일
편집: Sk Zeeshan Ali 2020년 2월 17일
I have the program as follows:
x = -2:0.2:2;
y = -2:0.2:3;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);
contour(X,Y,Z)
Now, I want to get a two-column matrix C that will give the (x,y) coordinates of a specific contour line, let us say for Z = 0.1. So, how to get this two-column matrix?

채택된 답변

Claudio Iturra
Claudio Iturra 2020년 1월 20일
편집: Image Analyst 2020년 1월 21일
x = -2:0.2:2;
y = -2:0.2:3;
[X,Y] = meshgrid(x,y);
hold on % to your meshgrid a specific value for your contour.
[x1,y1] = contour(X,Y,Z,[0.1 0.1],'*k') % x1 will be your "two-column matrix"
  댓글 수: 1
Sk Zeeshan Ali
Sk Zeeshan Ali 2020년 2월 15일
편집: Sk Zeeshan Ali 2020년 2월 17일
That's nice suggestion.
Now, can the contour line be made smooth without changing the meshgrid?

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

추가 답변 (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