Please solve the following two questions in Matlab. Please copy and paste the co
ID: 3813794 • Letter: P
Question
Please solve the following two questions in Matlab. Please copy and paste the code and take screenshots of the results and send it.
Q2) a. Write a Matlab function that calculates the surface area and volume of a cube. The equations to calculate the area and volume are: area 6 x2, Volume x3, where xis the length of the cube Name the function ARSAYR19yha. b. Write a Matlab function that calculates the surface area and volume of a cylinder. The equation to calculate the surface area is (2 r h 2 t ra where h is the length of the cylinder and r is its radius. The volume Rr2 h. Name the function areavolcylinder. c. Write a Matlab function that calculates the surface area and volume of a sphere. The equations to calculate the area and volume are: area 4Tr2, volume (43)Rr, where ris the radius of the sphere. Name the function areavolsphere. Test your functions AReavsRAquba, AReava,Syaandex, and AReavalsbpsRe with the following Matlab program This program is available on Folio under the lab assignment. s Program testlab 92. This program calculates the area an volume of cubes, cylinders and spheres. The program asks the user for the object cube, cylinder or sphere Then the program uses the user-defined Matlab functions aka........... a.Explanation / Answer
a)
function [areaa,vol] = areavolcube(x)
areaa=6*x*x
vol= x*x*x
end
b)
function [areaa,vol] = areavolcylinder(h,r)
areaa= 2*3.14*r*h + 2* 3.14*r*r
vol= 3.14*r*r*h
end
c)
function [areaa,vol] = areavolsphere(h,r)
areaa= 4*3.14*r*r
vol= (4/3)*3.14*r*r*r
end