You are on page 1of 1

function [P] = polyprop(test) %This is primary function

x = test(:,1)
y = test(:,2)
polygon.numsides = length(test)
polygon.area = area(test)
polygon.perimeter = perimeter(test)
polygon.centroid = centroid(p)
polygon
end %polyprop
function per = perimeter(test)
for i = 1:length(test);
tot = 0;
%

Y = 1:length(y);
tot = tot + sqrt((x(i)-x(i+1)).^2 + (sqrt(y(i)-y(i+1)).^2))

per = tot
end
end
function[A] = polyarea(x)
a=0;
alpha = length(x) - 1;
for i = 1:alpha;
a = a + abs((x(i,1).*x(i+1,2) - x(i+1,1).*x(i,2)));
end
[A] = .5.*a;
end

You might also like