Polygons with true and false statements
2 views (last 30 days)
Show older comments
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
Answers (1)
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
See Also
Categories
Find more on Elementary Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!