 Details
 Parent Category: Programming Assignments' Solutions
We Helped With This MATLAB Programming Homework: Have A Similar One?
Category  Programming 

Subject  MATLAB 
Difficulty  College 
Status  Solved 
More Info  Numerical Analysis Assignment Help In Matlab 
Short Assignment Requirements
Assignment Description
University at Buffalo
EAS 230 – Fall 2016 – Final Examination
DURATION: 2 hours
SCORE: /100 (max 110)
Instructions:
1. Do not open the exam booklet until you are told to do so.
2. This exam booklet consists of 11 total pages: this cover page, 1 page of Reference Materials and 8 problems.
3. The back of each problem page was left empty so you can write on it, if you wish. The cover page and the reference material page can be considered scrap papers and will not be graded.
4. You must place your UB Card (or other form of valid ID) on the desk in front of you during the exam.
5. No electronic devices, including calculators, and no outside “reference sheets” are allowed.
6. No bathroom breaks except for students having health problems.
7. Your electronic devices (cell phone, tablet, etc.) should be placed in your backpack which must be zipped/closed and placed on the floor at the classroom blackboard.
8. Writing on body, clothes, etc. is considered cheating and may result in a grade of zero on a problem—or a grade of zero for the entire exam.
9. Be sure to write your name and person number on each page.
10. Be sure you have all pages of the exam booklet and they are all stapled together.
11. To get full credit, you must show all work in this booklet (you may write on the back of each sheet).
12. You must stop writing when told to do so or you will receive a grade of zero on the problem—or a grade of zero for the entire exam.
13. If you have a question, please remain seated, raise your hand and wait for a proctor to come to you.
14. You must turnin everything: your exam booklet, your “bubblesheet” (if any), and your scrap paper (however, the scrap paper will not be graded).
15. When you turnin your exam papers, you must fillout the signin sheet with your name, person number, lab section and signature.
EAS 230 – Fall 2016 – Final Exam Page
Reference Materials
Some of the MATLAB builtin functions and their descriptions:
MATLAB Functions  Description 
size()  Returns the matrix dimensions [#rows #columns] 
length()  Returns the length of a vector (number of elements) 
det()  Returns the determinant of a square matrix 
inv()  Returns the inverse of a square matrix 
ones()  Returns a matrix where all entries are ones 
zeros()  Returns a matrix where all entries are zeros 
eye()  Returns the identity matrix 
Problem 1 (10 pts)
Write the output of the following commands when executed sequentially in MATLAB command window, if the command is not suppressed with (;) the output should be displayed.
 If variables are assigned names write the output as “ variable name = the value you calculate”  If variables are not assigned names write the output as “ ans = the value you calculate “  if MATLAB returns error, write “error” and the reason of that error.
clear
>> A = [2:2:2; 1:3]
>>[m , n] = size(A)
>> Asq = A.^2
>> AAM = A * A
>> AAS = A + Asq
>> det(A)
>> inv(A)
>> A(3,:) = 2:2:6
>> det(A)
Problem 2 (20 pts)
a. (10 points) Complete the following script to produce the adjacent figure
close all x = :pi/20:;
(x, , , cos(x),'.'); ('sin(x)','cos(x)'); axis([]);
('angle in radians')
('f(x)')
('Plot of sin(x) and cos(x) from 2pi to 2pi')
 on
Hasn’t been given yet ^{ }
b. (10 points) Write the output of the following Matlab scripts as it appears in the command window?
i. (5 points)
clear a = 1; while a < 8 if a == 3 a = a * 2; continue;
end
fprintf('value of a: %d ', a); a = a + 1; end

ii. (5 points)
clear A = [5 3 7 4]; iter = 0; M = A(1); for ii = 1:length(A) iter = iter+1; if A(ii) > M M = A(ii); end
disp(['iter:' num2str(iter) ' M = ' num2str(M)]) end
Problem 3 (15
Given the function get_product shown below, write the output of the commands shown after the function end as they are displayed in the command window.
function PRODUCT = get_product(MATRIX_A,MATRIX_B)
[RA,CA] = size(MATRIX_A); [RB,CB] = size(MATRIX_B); if (RA ~= CA)  (RB ~= CB)
error('Either one of the matrices entered or both are not square') elseif (RA ~= RB)
error('Matrices dimensions are not the same')
elseif det(MATRIX_A) >= det(MATRIX_B) PRODUCT = MATRIX_A * MATRIX_B; else
PRODUCT = MATRIX_B * MATRIX_A; end
end % end of the function
>> get_product ([1 1 ; 0 1] , [1 1 ; 1 0])
>> get_product ([1 1]' , [1 1])
>> get_product (ones(2) ,[1 1 ; 1 0])
>> get_product (eye(2) , [0 1 ; 1 0])
>> get_product (eye(3) , zeros(2)])
4 (10
Use the proper elimination matrix/matrices to determine the L and U decomposition of the
2 1 matrix 𝐴 = [ ],
6 9
a. (4 points) Without partial pivoting (permutation),
b. (6 points) With partial pivoting (permutation),
Hasn’t been given yet ^{ }
5 (10
Use Cramer’s rule to solve the following system of equations:
3𝑥_{1 }+ 𝑥_{2} = 3
2𝑥_{1 }− 𝑥_{2 }= 7
Hasn’t been given yet ^{ }
6 (15
For the following system of equations
𝑥_{1 }+ 2𝑥_{2 }= 4
2𝑥_{1 }− 𝑥_{3 }= 1
2𝑥_{2 }+ 𝑥_{3 }= 5
a. (2 pt) Rewrite the system of equations in 𝐴𝐱 = 𝐛 form.
b. (4 pts) find rank(𝐴) and rank(𝐴𝐛) by using Gaussian elimination to reduce 𝐴 and (𝐴𝐛) to row echelon form (REF).
c. (2 pt) With this information, determine whether the system of equations is consistent or inconsistent.
d. (4 pts) If the system is consistent, find the solution (i.e. determine 𝑥_{1}, 𝑥_{2} and 𝑥_{3}) by performing backsubstitution.
e. (3 pts) If each row of matrix 𝐴 can be considered as a row vector in a set of vectors 𝑆 = {𝐑_{1}, 𝐑_{2}, 𝐑_{3}}. From your solution of part b, is this set of vectors linearly dependent or independent and what is its span?
Hasn’t been given yet ^{ }
7 (10
If a system of equations can be written in the form 𝐿 𝑈 𝐱 = 𝐛 as
1 [2 0  0 1 −0.5  0 1 0] [0 1 0  2 −4 0  0 𝑥_{1 }4 −1] [𝑥_{2}] = [1] 0.5 𝑥_{3 }5 
where L and U are the Lower and Upper triangular matrices, respectively.
a. (8 pts) solve this system of equations using forward and back substitution.
b. (2 pts) Rewrite this system in the format 𝐴 𝐱 = 𝐛
Hasn’t been given yet ^{ }
Page
8 (20 pts)
a. (6 points) Find the eigenvalues and eigenvectors of the matrix [^{1 4}]
2 3
b. (14 points) The following homogeneous linear system of differential equations is required to be solved by diagonalization:
𝐱^{′ }= [^{−1 −3}] 𝐱 with the initial conditions [^{𝑥}^{1}^{(0)}] = [^{0}] where 𝐱^{′ }= ^{𝑑} 𝐱 .
2 4 𝑥_{2}(0) 1 𝑑𝑡
If the eigenvalues of this system are 1 and 2 and the corresponding eigenvectors are
−3 −1
𝐱_{𝟏 }= [ ] and 𝐱_{𝟐 }= [ ]
2 1
a. (2 pts) Find the matrix of the eigenvectors 𝑋,
b. (3 pts) Show that the matrix 𝑋 is not singular and find its inverse 𝑋^{−1} ,
c. (1 pt) Find the diagonal matrix 𝛬,
d. (4 pts) Use the substitution 𝐱 = 𝑋 𝐲 and find the general solution of the system, i.e., find
𝑥^{1}
𝐱 = [𝑥_{2}] in terms of 𝑡.
e. (4 pts) Use the initial conditions to determine the arbitrary constants and write the solution in its final form.
Hasn’t been given yet ^{ }
Page