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

Create a function that will accept the radius of a cylindrical disk, the thickne

ID: 3544305 • Letter: C

Question

Create a function that will accept the radius of a cylindrical disk, the thickness of the cylindrical disk, the number of cylindrical holes that have been cut into this disk, and the radius of these cylindrical holes.  All the holes have the same radius. (You may assume that the sum of the holes will not be bigger than the disk.)  Your function should calculate the volume of the disk (need to subtract the volume of the holes from the volume of the disk) and the surface area of the disk (need to subtract the area corresponding to the ends of the holes and add the area corresponding to the side of the holes).

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The script file should prompt the user (by employing the input function) to enter the radius of the disk, the thickness of the disk, the number of holes, and the radius of the holes.  Call the function with the values the user entered.

Explanation / Answer

Save the function file below as disk.m (name is important).


function [V,A] = disk(R,T,Nh,r)

V = pi*(R^2)*T - Nh*pi*(r^2)*T;

A = 2*pi*R*(T+R) - 2*Nh*pi*r^2 + 2*pi*r*T;

end



matlab script file, you may save this by any name but save it in same folder in which you have saved the disk.m


clc

clear

R = input('Enter radius of the disk: ');

T = input('Enter Thickness of the disk: ');

Nh = input('Enter the number of holes: ');

r = input('Enter radius of the holes: ');


[V,A] = disk(R,T,Nh,r);


a1 = sprintf(' volume of the disk = %f',V);

disp(a1)

a2 = sprintf('surface area of the disk = %f ',A);

disp(a2)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote