# MatlabWrite a function called that takes a scalar input . …

Matlab Write a function called that takes a scalar input . It needs to return an output called that is the area of a circle with radius and a second output, that is the circumference of the same circle. You are allowed to use the built-in function

**Answer**

In MATLAB, you can create a function that calculates the area and circumference of a circle given its radius. In this case, we will define a function called “circle_properties” that takes a scalar input “radius”. The function will then calculate the area and circumference of the circle, and return them as two separate outputs.

To start, let’s define the function and the input parameter:

“`matlab

function [area, circumference] = circle_properties(radius)

“`

Next, we can calculate the area of the circle. The formula for the area of a circle is given by:

“`matlab

area = pi * radius^2;

“`

Here, we use the value of π (pi) and the radius squared to compute the area of the circle.

Next, we can calculate the circumference of the circle. The formula for the circumference of a circle is given by:

“`matlab

circumference = 2 * pi * radius;

“`

Here, we multiply the value of π (pi) by the radius and then double the result to obtain the circumference of the circle.

Finally, we will return the calculated values as the output of the function:

“`matlab

function [area, circumference] = circle_properties(radius)

area = pi * radius^2;

circumference = 2 * pi * radius;

end

“`

By calling this function with a specific radius value, you can obtain both the area and circumference of the circle. For example:

“`matlab

radius = 5;

[area, circumference] = circle_properties(radius);

disp([‘Area: ‘, num2str(area)]);

disp([‘Circumference: ‘, num2str(circumference)]);

“`

In this case, for a circle with a radius of 5, the output will be:

“`

Area: 78.5398

Circumference: 31.4159

“`

The function “circle_properties” can be used to easily calculate the area and circumference of any circle given its radius. This function takes advantage of the built-in value of π (pi) provided by MATLAB and simplifies the calculation process.