Beruflich Dokumente
Kultur Dokumente
NOTE:
1. All problems should be performed in a group of two or three students.
2. The assignment will be marked out of 15
3. Method of Submission: soft copy through D2L.
4. To earn full credit, you have to submit the codes for all problems on the assignment in
one single “.m” file.
a. To do so, in MATLAB, select new script and write the commands line by line for
each exercise.
b. Your command should start by displaying your names, ID and section.
5. Save your file as A1_SECTION_#_ your student number (YS#)_your partner student
number (YPS#). (e.g.: A1_SECTION_2_500156666_500156345.m)
6. Upload the script file (A1_SECTION_#_YS#_YPS#.m) onto D2L before the due date. To
do so, go to the CEN100 course page, click on “Assessment”, then select “MATLAB # 2 -
Due October 9th” and upload the file. Only one submission per group is allowed.
Question 1
Use MATLAB’s FZERO operator to find the roots of the following functions in the given interval.
a) 6𝑐𝑜𝑠𝜃 = 𝜃/5 on [𝜋 , 2𝜋] (1 mark)
−0.01𝑥 [0 , 3]
b) 𝑒 = 7𝑥 − 2 on (1 mark)
Question 2
Question 3
a) Write a function file called q4.m containing the following nonlinear equations.
Question 4
You have learnt how to solve a system of linear equations using elementary operations. Now, use
MATLAB operators and matrices to solve the system of linear equations below (i.e. what is x1, x2 and
x3?):
65x1 + 84x2 + 16x3 = 546
81x1 + 105x2 + 20x3 = 682
84x1 + 110x2 + 21x3 = 713
a. Create a coefficient matrix, M, which is made up of the coefficients of each variable. Each row of
the matrix should correspond to each equation and the columns should represent each variable
(1 Mark)
b. Create a constant column matrix, N, for the constants on the right side of the equations. Again,
each row should correspond to the constants of each equation.
(1 Mark)
c. Find X, the row matrix for the variables for which
(1 Mark)
𝑀 ∗ 𝑋 = 𝑁 and 𝑋 = 𝑀\𝑁
Question 5
The population (in millions) of London by decade in the 19th century is listed in the following
table.
Years Population
since 1800 (millions)
1 0.8795
11 1.040
21 1.264
31 1.516
41 1.661
51 2.000
61 2.634
71 3.272
81 3.911
91 4.422
c) Plot the best-fit quadratic equation on the same figure as the given data using crosses
(x). Hint – Use the command ‘hold on’
i. Create a polynomial (not a function), p_fit, similar to fun using t instead of T.
ii. Plot t vs p_fit. For your legend, call the given data ‘Population Count’ and the
quadratic equation ‘Population Fitted’. (2 marks)
d) Use MATLAB’s ‘polyder’ tool to find the coefficients for the differential of fun. You will
get a vector which you can call ‘r’. E.g. 𝑟 = 𝑝𝑜𝑙𝑦𝑑𝑒𝑟(𝑞)
i. Define a function called ‘f_diff’ using r and T. (1 mark)
Evaluate ‘fun’ and ‘f_diff’ at a or T = 91 and h = 10 to solve for the population estimate
in 1901. (1 mark)
Note that the corresponding coefficient vectors and T will be input arguments for the
functions. E.g. 𝑓(𝑎) = 𝑓𝑢𝑛(𝑞, 𝑇) and 𝑓 ′ (𝑎) = 𝑓𝑑𝑖𝑓𝑓 (𝑟, 𝑇)
Due date October 9th, 2019 at 3:00 PM through D2L
Evaluation
Question 1
A 1.0
B 1.0
Question 2
A 1.0
B 1.0
Question 3
A 1.0
B 1.0
Question 4
A 1.0
B 1.0
C 1.0
Question 5
A 1.0
B 1.0
C 2.0
D 1.0
E 1.0