Question: Please answering the following question using MATLAB: 1) Convert the program into a function. It will have two inputs, the radius and height of the
Please answering the following question using MATLAB:

1) Convert the program into a function. It will have two inputs, the radius and height of the cylinder. Do not prompt the user for the inputs, since they will be entered as arguments on the command line when the function is run.
2) The function calculates five geometric parameters: area of end, perimeter of end, area of side, total surface area, and volume. Modify the program so that the calculation of each of these parameters is in a separate local function.
3) The final function should produce the exact same result as the original program. When run with input values of 3 and 5 (radius and height respectively) it should give the result

% Prompt user for radius and height % of cylinder, calculate various % geometric parameters % user input r = input ('Enter radius: '); h = input ('Enter height: '); % geometry a = pi* r^2; p = 2*pi* r; aside = p*h; atot= 2*a + aside; v = a*h; % area of end % perimeter % area of side % surface total % volume area % print results fprintf('end area fprintf('perimeter fprintf'side area fprintf('total area fprintf( volume %6.2f ", 46.2f ", %6.2f ", $6.2f ', %6.2f ', a) p) aside) atot.) v)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
