How to find whether the point lies with in the enclosed boundary region or not

2 views (last 30 days)
Hello,
I have a set of points for which i have created a enclosed region using boundary function.
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!

Answers (1)

KSSV
KSSV on 11 Mar 2022
Read about inpolygon.
  5 Comments
Simon Chan
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);
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
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');

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!