You are on page 1of 2

ME 32200 – Computer Methods in

Engineering
Homework Assignment 3
Dimitrios Fafalis, PhD
dfafalis@ccny.cuny.edu
due Friday, February 15, 2019 – for 5AD

Students’ names & ID:

Submit your files and a report with the results on Blackboard by due date.
For a quick reference for homework 1 read sections 1-4 of Appendix B of your textbook.
PROBLEM 1. points 10 – Use MATLAB
The height of a small rocket y can be calculated as a function of time after blastoff with the
following piecewise function:


38.1454t + 0.13743t ,
3
for 0 ⩽ t < 15
y(t) = 1036 + 130.909(t − 15) + 6.18425(t − 15) − 0.428(t − 15) , for 15 ⩽ t < 33
2 3


2900 − 62.468(t − 33) − 16.9274(t − 33)2 + 0.41796(t − 33)3 , for t > 33
Develop a well-structured pseudocode function to compute y as a function of t. Note
that if the user enters a negative value of t or if the rocket has hit the ground (y ⩽ 0) then
return a value of zero for y. Also, the function should be invoked in the calling program as
height(t). Write the algorithm in MATLAB!.
PROBLEM 2. points 10 – Use MATLAB
The following table gives the approximate values of the static coefficient of friction µ for
various materials
Materials µ
Metal on metal 0.20
Wood on wood 0.35
Metal on wood 0.40
Rubber on concrete 0.70

To start a weight W moving on a horizontal surface, you must push with a force F , where
F = µW . Write a MATLAB program that uses the switch structure to compute the force
F . The program should accept as input the value of W and the type of materials.

1
PROBLEM 3. points 10 – Use MATLAB
Plot the function
( )
y = 10 1 − e−x/4
over the interval 0 ≤ x ≤ xmax , using a while loop to determine the value of xmax such that
y(xmax ) = 9.8. Properly label the plot. The variable y represents force in newtons, and the
variable x represents time in seconds.

PROBLEM 4. points 10 – Use MATLAB


Use a for loop to determine the sum of the first 10 terms in the series 5k 3 , k = 1, 2, · · · , 10

PROBLEM 5. points 10 – Use MATLAB


Determine how long it will take to accumulate at least $10,000 in a bank account if you
deposit $500 initially and $500 at the end of each year, if the account pays 5 percent annual
interest. Hint: use a while loop.

PROBLEM 6. points 10 – Use MATLAB


The height and speed of a projectile (such as a thrown ball) launched with a speed of v0 at
an angle A to the horizontal are given by

h(t) = v0 t sin A − 0.5gt2 (1)



v(t) = v02 − 2v0 gt sin A + g 2 t2 (2)
where g is the acceleration due to gravity. The projectile will strike the ground when h(t) = 0,
which gives the time to hit thit = 2(v0 /g) sin A.
Use the switch structure to write a MATLAB program to compute the maximum height
reached by the projectile, the total horizontal distance traveled, or the time to hit. The
program should accept as input the users choice of which quantity to compute and the
values of v0 , A, and g. Test the program for the case where v0 =40 m s−1 , A = 30o , and g =
9.81 m s−2 .

PROBLEM 7. points 10 – Use MATLAB


Use a while loop to determine how many terms in the series 2k , k = 1, 2, 3, . . . , are required
for the sum of the terms to exceed 2000. What is the sum for this number of terms?

PROBLEM 8. points 10 – Use MATLAB


Rewrite the following statements to use only one if statement.
1 if x < y
2 i f z < 10
3 w = x∗y∗ z
4 end
5 end
Give three examples with numbers of x, y, z of your choice.

You might also like