An interactive introduction to MATLAB

(Jeff_L) #1
C.3scripts and functions 83

c.3 Scripts and Functions



  1. Scripts
    A cylindrical silo with radiusrhas a spherical cap roof with radiusR, as
    shown in Figure 25. The height of the cylindrical portion isH. Write a
    script file that determines the heightHfor given values orr,R, and the
    volumeV. In addition the script should also calculate the surface area of
    the silo. The volume of the cylinder is given by:


R

r

H
r

h

θ
R

Figure 25: Silo

Vcyl=πr^2 H,

and the volume of the spherical cap is given by:

Vcap=^1
3
πh^2 (3R−h),

whereh=R−Rcos(θ)andθis calculated fromsin(θ) =Rr. The height
Hof the cylindrical part can be expressed by:

H=
V−Vcap
πr^2
The surface area of the silo is obtained by adding the surface areas of
the cylindrical part and the spherical cap:

S=Scyl+Scap=2πrH+2πRh
Free download pdf