How to calculate the coordinates of the overlaped points over a polygon?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
DGM
on 5 Jul 2025
Edited: DGM
on 5 Jul 2025
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!