MATLAB Answers

How to get coordinates for a specific contour line?

16 views (last 30 days)
Sk Zeeshan Ali
Sk Zeeshan Ali on 20 Jan 2020
Edited: Sk Zeeshan Ali on 17 Feb 2020 at 6:43
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?

  0 Comments

Sign in to comment.

Accepted Answer

Claudio Iturra
Claudio Iturra on 20 Jan 2020
Edited: Image Analyst on 21 Jan 2020 at 1:20
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 Comment

Sk Zeeshan Ali
Sk Zeeshan Ali on 15 Feb 2020 at 10:02
That's nice suggestion.
Now, can the contour line be made smooth without changing the meshgrid?

Sign in to comment.

More Answers (0)

Sign in to answer this question.