$35
ENSC 180: Introduction to Engineering Analysis
Assignment 2
Note: MATLAB codes should include definition of all variables; headings to identify
the program structure plan; and appropriate captions and labels for tables and
figures. M-files together with your input/output for each problem should be submitted.
Marks will be deducted for solutions that are unrealistic/impractical (as future
engineers students should learn to think practically) and poorly documented.
1. A solid sphere of radius r and density ρs is placed in a fluid of density ρ0. The
sphere sinks to a depth of h. The volume of sphere below the fluid surface is
𝜋𝜋(3𝑟𝑟ℎ2−ℎ3)
3 . Develop a MATLAB function to calculate h based on input values r, ρs
and ρ0. Your function should prompt a user to input r, ρs and ρ0 and print the
output as ‘The sphere depth below the fluid surface is:’. Test your code with
r=40mm, ρs =0.6 g/mm3 and ρ0 =1.0 g/mm3
. Next, develop a function that
calculates the ratio h/r for a given (ρs/ρ0) ratio. Plot the graph of h/r vs. (ρs/ρ0).
Discuss the results using your knowledge of engineering and Physics. (25 marks)
2. The height of a rocket is approximated by the following equation.
H = 2.13t
2 – 0.0013t
4 + 0.000034t
4.751
where H is the height (meters) and t is the time (seconds).
a) Create a function, R_motion to calculate the rocket height and speed at a given
time; and b) create a function handle to R_motion. C) plot the rocket height and
velocity with time using a function named R_motionplot. (25 marks)
3. Legendre and Chebyshev polynomials are a class of orthogonal polynomials used
in the solution of engineering problems, especially in numerical integration.
Consider the Legendre polynomial (693x6
-945x4
+315x2
-15)/48 and the Chebyshev
polynomial (32x6
-48x4
+18x2
-1). Find the roots of these polynomials in the range
-1.0 ≤x≤ 1.0 to an accuracy of 0.001. Comment on the behaviour of roots. (25 marks)
4. Fourier transforms are widely used in signal processing, control theory, earthquake
engineering and other engineering applications. It involves representing an
arbitrary periodic function by a trigonometric series. Consider a periodic function
of the following form:
𝑓𝑓(𝑥𝑥) = −𝑘𝑘 𝑤𝑤ℎ𝑒𝑒𝑒𝑒 − 𝜋𝜋 < 𝑥𝑥 < 0
𝑘𝑘 𝑤𝑤ℎ𝑒𝑒𝑒𝑒 0 < 𝑥𝑥 < 𝜋𝜋
𝑎𝑎𝑎𝑎𝑎𝑎 𝑓𝑓(𝑥𝑥 + 2𝜋𝜋) = 𝑓𝑓(𝑥𝑥)
The above function is approximated using the Fourier series,
∑ 𝑏𝑏𝑛𝑛
∝
𝑛𝑛=1 sin(𝑛𝑛𝑛𝑛) 𝑤𝑤ℎ𝑒𝑒𝑒𝑒𝑒𝑒 𝑏𝑏𝑛𝑛 = 2𝑘𝑘(1−𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐)
𝑛𝑛𝑛𝑛 . Write a MATLAB code to approximate
f(x) using the above series and determine an appropriate value (i.e. N) for the upper
limit of the series expansion. Comment on the behavior of each term of the series
and the solution for f(x) by using different values for N. Use k=1 in your numerical
trials. (25 marks)