How to analyse this data set?

1 次查看(过去 30 天)
Mo Ba
Mo Ba 2017-5-4
编辑: KSSV 2017-5-4
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.

采纳的回答

KSSV
KSSV 2017-5-4
编辑:KSSV 2017-5-4
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by