How to analyse this data set?

1 vue (au cours des 30 derniers jours)
Mo Ba
Mo Ba le 4 Mai 2017
Modifié(e) : KSSV le 4 Mai 2017
Hello experts,
I have some data points and can easily plot them on a figure in MATLAB. For some reason, I need to find out what data points are located inside some rectangle areas as can be seen in attached picture. In this picture, black dots represent my data points and red rectangles represent mentioned areas. In this example, how can I search into my data points and see whether they belong to any rectangle or not? I need to have a list of all members (data points) for each rectangle. I hope I explained my problem clearly. Any idea and advice is appreciated.

Réponse acceptée

KSSV
KSSV le 4 Mai 2017
Modifié(e) : KSSV le 4 Mai 2017
doc inpolygon
N = 30 ;
[X,Y] = meshgrid(1:N,1:N) ;
plot(X,Y,'.k','markersize',10) ;
%%polygon coordinates
Rect = [ 8.5369 23.4840
17.4539 23.4840
17.5230 16.7493
7.6382 16.4869
8.5369 23.4840] ;
hold on
plot(Rect(:,1),Rect(:,2),'r');
%%get points inside the polygon
idx = inpolygon(X,Y,Rect(:,1),Rect(:,2)) ;
%%points inside polygon
xi = X(idx) ; yi = Y(idx) ;
plot(xi,yi,'ob')

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by