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

CS 137 a/Local/Temp/Temp 1-HW01%20(1)2ip/HW01-Drillproblems.pdf Function Name: c

ID: 3874994 • Letter: C

Question

CS 137 a/Local/Temp/Temp 1-HW01%20(1)2ip/HW01-Drillproblems.pdf Function Name: cookieCutter Inputs: 1. (double) Interior angle of your cookie cutter Outputs: 1. (double) Number of sides your cookie cutter will have Background: You decide to take a trip to the Invention Studio. When you arrive, you find that theyre doing a fun challenge involving cookie cutters! Since you like cookies, you decide to participate. You are handed a slip of paper containing an angle measurement, and you have to make a cookie cutter shaped like a regular polygon with that particular interior angle. Do it successfully and you can keep your cookie cutter! You decide to use your MATLAB skills to help you figure out how to make your cookie cutter. Function Description: A regular polygon is a polygon where all the sides and angles are the same, like a square or an equilateral triangle. You also remember that a formula that relates the number of sides of a regular polygon to its interior angle is 180 (n-2) In this equation, is the interior ange in degrees and u is the number of sides.wrtea nurct on in MATLAB that calculates the number of sides given the interior angle Example cook ieCutter(90) => 4 Notes

Explanation / Answer

Given that,

interior_angle = 180(n-2)/n

so,

interior_angle*n = 180n - 360

So,

180n - interior_angle*n = 360

So,

n(180-interior_angle) = 360

so,

n = 360/(180-interior_angle)

The Formula for number of sides in a regular polygon given interior angle = 360/(180 - interior_angle).

Create a file named cookieCutter.m and paste given code into it.

cookieCutter.m

function [n_sides] = cookieCutter(angle)
n_sides = 360/(180-angle);  
end

Sample Run:

>> n = cookieCutter(60)
n = 3
>> n = cookieCutter(90)
n = 4
>> n = cookieCutter(150)
n = 12
>> n = cookieCutter(120)
n = 6