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 (693×6

-945×4

+315×2

-15)/48 and the Chebyshev

polynomial (32×6

-48×4

+18×2

-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)