How to calculate the coordinates of the overlaped points over a polygon?
조회 수: 1 (최근 30일)
이전 댓글 표시
The example on which i tried to apply the inpolygon is:
solux=[5.95,6.40,6.2,6.3,6.42,6.81,7.26,7.76,6.5,8.1,8.17,8.6,9.06,9.5,8.1]
and soluy = [37.5,37.3,36.8,36.3,35.8,35.5,35.3,35.3,35.1,35.02,34.5,35.07,34.7,34.7,34.02];
and the coodinates of polygon is attached in the attachment. I have used the 'inpolygon(solux,soluy,xv,yv)' to solve the problem, but im unable to draw the coordinates of the polygon into 'xv' and 'xy'. Please find the files for coordinates of the polygon in 'trialdataofcoordinates.mat' file. Please help me out.
댓글 수: 0
답변 (1개)
DGM
2025년 7월 5일
편집: DGM
2025년 7월 5일
Plot the data and look at it. The data points don't appear to be anywhere near the polygons.
% the data
load trialdataofcoordinates.mat
solux = [5.95,6.40,6.2,6.3,6.42,6.81,7.26,7.76,6.5,8.1,8.17,8.6,9.06,9.5,8.1];
soluy = [37.5,37.3,36.8,36.3,35.8,35.5,35.3,35.3,35.1,35.02,34.5,35.07,34.7,34.7,34.02];
% plot the points
scatter(solux,soluy); hold on
% plot the pgons and calculate intersection
isinpgon = false(numel(mycoordinates),numel(solux));
for k = 1:numel(mycoordinates)
plot(mycoordinates{k}(:,1),mycoordinates{k}(:,2),'k') % assuming these are [x y]
isinpgon(k,:) = inpolygon(solux,soluy, ...
mycoordinates{k}(:,1),mycoordinates{k}(:,2));
end
% clearly, none of the points are in any of the pgons
nnz(isinpgon)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!