Contour not taking into account edge of domain
Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5);Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5); Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5); contour, convhull, edges, polygon MATLAB Answers — New Questions