17. As shown in the figure, the area of a convex polygon can be calculated by adding...
Question:
17. As shown in the figure, the area of a convex polygon can be calculated by adding the area of the triangles that the polygon can be divided into. Write a userdefined MATLAB function that calculates the area of a convex n-sided polygon. For the function name and arguments, use A = APolygon(Crd). The input argument Crd is a two-column matrix where each row contains the coordinates of a vertex (first column is the x coordinate and the second column is the y coordinate). The vertices are listed in the order that they are connected to form the polygon (i.e., coordinates of point A in the first row, point B in the second, and so on). The output argument A is the area of the polygon. Write the code of APolygon such that it has a subfunction that calculates the area of a triangle for given vertices’
coordinates. Use APolygon to calculate the area of the polygon shown in the figure. The coordinates of the vertices are: A(1, 1), B(7, 2), C(10, 5), D(9, 11), E(6, 12), F(1, 12), G(–3, 8), H(–4, 4).
Step by Step Answer: