Question: Create a function in MATLAB that finds either the Area A = nr2 or the Circumference: C = 2tr of a circle of radius r.

 Create a function in MATLAB that finds either the Area A

Create a function in MATLAB that finds either the Area A = nr2 or the Circumference: C = 2tr of a circle of radius r. Use a Switch-case statement to solve the problema. Things you must do: Create a function in MATLAB named: function result = calc_circle (r,x) the first parameter, r, represents the radius of the circle, while the second parameter x, determines the type of calculation to be performed (1 for Area, 2 for Circumference) Save the code for your function into a file named: calc_circle.m Test the function from the MATLAB command window to make sure it works as expected, e.g: >> - 1; >> A = calc_circle(r, 1) A= 3.1416 >> = calc_circle(r, 2) 6.2832 Using an illegal value should produce a warning message, e.g.: >> r = 3; >> calc_circler, 5) only 1 or 2 is legal values for x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!