Question: Regular Polygon Sides: 2 1 Regular Polygon Side Length: 2 . 5 Right Triangle Side Length 1 : 9 . 3 Right Triangle Side Length
Regular Polygon Sides:
Regular Polygon Side Length:
Right Triangle Side Length :
Right Triangle Side Length :
Rectangle Side Length :
Rectangle Side Length :
In MatLab: First, your program should determine if the inputs are formatted properly. The rules are as follows:
numSides must be a positive integer number with values greater than or equal to
When numSides is or sideLengths can either be a scalar or an array with two values.
When numSides is greater than sideLengths must be a scalar.
To determine if a number is an integer, you can use the rem function. rem returns the remainder of whole
number division. It has the following syntax:
remainder remnumerator denominator;
Where remainder is the remainder of numeratordenominator To use this to find whether a
number is an integer, use rem in the following way:
remainder remnumber;
When number is an integer, remainder will be Otherwise, remainder will be nonzero.
To determine how many numbers are contained in an array, use the length function. The length
function has the following syntax:
N lengtharrayName;
Where N is the number of elements ie the number of numbers contained in array arrayName.
different ways of calculating area of the polygon.
When numSides is and sideLengths is an array with two numbers, you will calculate the
area of a right triangle, where the two numbers inside of sideLengths are the sides of the
triangle that are not the hypotenuse.
When numSides is and sideLengths is an array with two numbers, you will calculate the area of a rectangle where the two numbers inside of sideLengths are your two different lengths for the sides of your rectangle.
In all other valid cases, the scalar sideLengths is the length of all fsides of the polygon, no matter what numSides is
Thanks!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
