How to find whether the point lies with in the enclosed boundary region or not
2 views (last 30 days)
Show older comments
Hello,
Are there some ways to find whether a point lies with in the enclosed region or not?.Please see the attached picture.for ex; if i want to know whether (x = 20 y =5) is with in the enclosed region or not.
Thanks!
0 Comments
Answers (1)
KSSV
on 11 Mar 2022
Read about inpolygon.
5 Comments
Simon Chan
on 12 Mar 2022
Vertices are not arranged in a correct order and function boundary do the job for you.
clear; clc;
load('xy.mat')
xq = 10;
yq = 10;
pgon1 = polyshape(xv,yv);
subplot(1,2,1)
plot(pgon1);
hold on
plot(xq,yq,'r*');
title('Use xv and yv');
subplot(1,2,2);
bd1 = boundary(xv,yv);
pgon1b = polyshape(xv(bd1),yv(bd1));
plot(pgon1b);
hold on
plot(xq,yq,'r*');
title('Use xv and yv with function boundary');
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!