define a functionthe radius of a circle is passed


Define a function:

The radius of a circle is passed to the function to input argument  rad; the function computes the area of this circle and stores it in the output argument area. In the function header, we have reserved word function, then an output argument area followed by an assignment operator =, then the name of the function (similar as the name of the M-file), and then the input argument  rad, that is the radius. As there is an output argument in the function header, anywhere in the body of the function we should assign a value to this output argument. This is how the value is returned from a function. In this situation, the function is easy and all we have to do is assign to the output argument area the value of the built-in constant pi multiplied by the square of the input argument rad.

The function can be exhibited in the Command Window by using the  type command.

>> type calcarea

function area = calcarea(rad)

% This computes the area of a circle

area = pi * rad * rad;

 

 

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: define a functionthe radius of a circle is passed
Reference No:- TGS0174788

Expected delivery within 24 Hours