Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 Background You are to create a program or set of programs to investigate the p

ID: 2074626 • Letter: 1

Question

1 Background You are to create a program or set of programs to investigate the properties of regular polygons. At a minimum, your program or set of programs must do the following: 1. Calculate the area of a regular polygon, given the number of sides and one of the following parameters: (a) Side length (b) Radius (c) Apothem 2. Calculate interior and exterior angles 3. Calculate the perimeter of a regular polygon, given the number of sides and the area 2 Requirement:s In this project, you must create · a MATLAB program or set of programs which will carry out required functions

Explanation / Answer

As the question asks, here is a MATLAB functions for different input conditions, where each function returns - area of polygon, interior angle, exterior angle and perimeter of polygon.

%=======================================================================%
%Code for given input :-
%n: number of sides
%side: length of each side
function [area,int_angle,ext_angle,perimeter] = polygon_side(n,side)
alpha = (2*pi)/n;
%Divide polygon into n triangles
apothem = side/(2*tan(alpha/2));
area = n*(0.5*apothem*side);

ext_angle = 360/n;
int_angle = 180-ext_angle;

perimeter = side*n;
end
%========================================================================%

%=======================================================================%
%Code for given input :-
%n: number of sides
%radius: of the circumcircle of the regular polygon
function [area,int_angle,ext_angle,perimeter] = polygon_radius(n,radius)
alpha = (2*pi)/n;
side = 2*radius*sin(alpha/2)

%Divide polygon into n triangles
apothem = radius*cos(alpha/2);
area = n*(0.5*apothem*side);

ext_angle = 360/n;
int_angle = 180-ext_angle;

perimeter = side*n;
end
%========================================================================%

%=======================================================================%
%Code for given input :-
%n: number of sides
%apothem: radius of incircle; perpendicular from center to side
function [area,int_angle,ext_angle,perimeter] = polygon_apothem(n,apothem)
alpha = (2*pi)/n;
side = 2*apothem*(tan(alpha/2));
%Divide polygon into n triangles
area = n*(0.5*apothem*side);

ext_angle = 360/n;
int_angle = 180-ext_angle;

perimeter = side*n;
end
%========================================================================%