ENSC 180: Introduction to Engineering Analysis

Assignment 5

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. Submit a .pdf report documenting your inputs and outputs in addition to a

separate zip-file containing all M-files. Marks will be deducted for solutions that are

unrealistic/impractical (as future engineers student should learn to think practically)

and poorly documented.

1. Write a MATLAB code to find the eigenvalues and eigenvectors of a 3×3 real

symmetric matrix. The program should ask a user to enter the 3×3 matrix and

output each eigenvalue and the corresponding eigenvector. You are not allowed to

use any MATLAB built-in functions except roots. Using [A]= [4 3 1;3 7 -1; 1 -1 9]

check the accuracy of your code by comparing with the eigenvalues and

eigenvectors obtained from the MATLAB eig command. (25 marks)

2.

(a) An eigenvalue problem is defined by the matrix equation, [K]-ꞷ

2

[M]= {0}, where

K is a real symmetric square matrix and [M] is a diagonal square matrix (same

order as [A]) with real positive elements. Given [A]= [4 3 1; 3 7 -1;1 -1 9] and

[M]= [1 0 0;0 2 0;0 0 3], find the eigenvalues ꞷ and the corresponding

eigenvectors using MATLAB. (10 marks).

(b) magic is a MATLAB command that can be used to create a special square matrix.

It has the property that the sums of the columns are the same, as are the sums of

the rows. Create a 6×6 magic matrix and using MATLAB commands find the sum

of each column, sum of each row and the sum of diagonals. Are these equal? (10

marks)

(c) Create a 4×4 magic matrix A. Use MATLAB to assemble a new matrix, B

=[

𝐴 2𝐴

𝐴

2 𝐴 + 2

] and check whether the sum of all rows, columns and diagonals of B

is the same by using MATLAB. (10 marks)

3. At time t=0, the engine of a rocket shuts down and it has reached a height of 500m

and rising at a velocity 125 m/s. Thereafter, the rocket is moving under the action

of gravity and its height, h, is expressed as a function of t.

h(t)=-4.9t2+125t+500

Using MATLAB symbolic calculations, find the velocity and acceleration of the

rocket as a function of time. Plot the height, velocity and acceleration in a single

figure using different colours and find the time to hit the ground using MATLAB

built-in functions. (15 marks).

4. A Fibonacci sequence is composed of elements created by adding the two previous

elements. The simplest Fibonacci sequence is 1,1,2,3,5,8,13,21………. Fibonacci

sequences have many examples in nature (e.g., the shell of the chambered nautilus

grows in accordance with a Fibonacci sequence). Write a MATLAB code to generate

a Fibonacci sequence and prompt a user to enter the first two numbers and the total

number of elements in the sequence. Your code should be able to plot the numbers in

a polar plot using the element number as the angle and the value of the element as the

radius. Show 3 sample polar plots generated by Fibonacci sequences. Check the ratio

of two adjacent numbers of a Fibonacci sequence. Do you see any trend as the

sequence grows? (30 marks).