You are on page 1of 2

Creating Scripts and Understanding Comments 5 CSC209

Creating m.file for the given scenarios


1. Suppose that we would like to calculate the volume of a cylinder of radius r and length l.
The area of the circle at the base of the cylinder is given by the equation

and the total volume of the cylinder will be

If the radius of the cylinder is 0.1 m and the length is 0.5 m. define the volume of the
cylinder using the MATLAB statements (Script file).
2. Suppose that a= 1 and b = 2. Evaluate the following expressions using MATLAB script

3. Assume that array c is defined as shown, and determine the contents of the following sub-
arrays:

Using MATLAB file script to define:

4. Suppose that x = 3 and y = 4. Use MATLAB to evaluate the following expression:

5. Suppose that a= 1, b = 2, and c= 3. Evaluate the following expressions using MATLAB

6. Use MATLAB script file for the following statements to obtain the function
for the range
Creating Scripts and Understanding Comments 5 CSC209

7. Suppose that u=1 and v= 3. Evaluate the following expressions using MATLAB script:

8. Suppose that x = 2 and y = -1. Evaluate the following expressions using MATLAB script:

9. Use one MATLAB script file to contain the following statements to answer the questions

i. What is the value of w(2,1) in the w array?


ii. What is the value of x(2,1) in the x array?
iii. What is the value of y(2,1) in the y array?
iv. What is the value of v(3)?
10. The distance traveled by a ball falling in the air is given by the equation

Use MATLAB script to calculate the position of the ball at time t = 5 s if x0 = 10 m,


v0 = 15 m/s, and a = - 29.81 m/sec2.
11. What do the following sets of statements do? What is the output from them?

You might also like