MATLAB Answers

Polygons with true and false statements

6 views (last 30 days)
Juan José Gómez Romero
Juan José Gómez Romero on 10 Jul 2020
Answered: KSSV on 10 Jul 2020
Hi. I'm trying to make a polygon with true and false statements in a meshgrid of linear spaces. I managed to make a circle and a square, but nothigh further than that. Here's the code for mi circle and square
Circle:
xv = linspace(-32,32,256);
yv = linspace(-32,32,256);
[mx my] = meshgrid(xv,yv);
dat1 = (mx.*mx + my.*my > 16);
figure(1);imshow(dat1);
Square:
dat = zeros(128,128);
vtamx = 32;
vtamy = 32;
dat(64-vtamy/2:64+vtamy/2,64-vtamx/2:64+vtamx/2) = 1;
imshow(dat);

  0 Comments

Sign in to comment.

Answers (1)

KSSV
KSSV on 10 Jul 2020
Read about inpolygon. You can define your required polygon vertices, and inpolygon will give you indices lying inside with 1 and lying outside with 0.

  0 Comments

Sign in to comment.