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

2 vues (au cours des 30 derniers jours)
HARI
HARI le 11 Mar 2022
Commenté : Walter Roberson le 12 Mar 2022
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!

Réponses (1)

KSSV
KSSV le 11 Mar 2022
Read about inpolygon.
  5 commentaires
Simon Chan
Simon Chan le 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');

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by