How to perform calculations on points found with inpolygon?
1 view (last 30 days)
Show older comments
Here is my code which is attempting to find the center of gravity by checking on the number of points with a particular polygon. Is there a way to add the values of these points within each polygon in addition to simply determining how many points there are?
while b-a > stop
r = b-a;
t = theta*r;
lam = a + t;
rho = b - t;
% Set the y-axis corners for polygon specification
c = jj;
d = jj+intj;
% Set the polygons:
xA = [a,a,lam,lam];
yA = [c,d,d,c];
xB = [lam,lam,rho,rho];
yB = [c,d,d,c];
xC = [rho,rho,b,b];
yC = [c,d,d,c];
% Use inpolygon to grab the number of points in each of the polygons
inA = inpolygon(RPM,BMEP,xA,yA);
inB = inpolygon(RPM,BMEP,xB,yB);
inC = inpolygon(RPM,BMEP,xC,yC);
% Determine the number of points in each polygon
x = numel(RPM(inA));
y = numel(RPM(inB));
z = numel(RPM(inC));
if x < z
a = lam;
else
b = rho;
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Elementary Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!