The perimeter looks right, but to make the area right either the first point must equal the last point or you need to extend the p_area by one more term, namely, (x(n)+x(1))*(y(n)-y(1)). Also you need to either ensure that your route around the polygon is clockwise or else you should take the absolute value of the result.
You should note that it is possible to avoid the for-loops here with a vectorized expression for both the perimeter and the area.
Best Answer