Question: Using MATLAB 17. As shown in the figure, the area of a convex polygon can be calculated by adding the area of the triangles that
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 user G defined MATLAB function that calculates the area of a convex n-sided polygon. For the function name H 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 coordi- nate 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 argu- ment 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), F1, 12), G(-3, 8), H(-4, 4)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
