310 MATLAB\'s qr command, which we introduced in Exercise 3.2.48, can be used to
ID: 3733393 • Letter: 3
Question
310 MATLAB's qr command, which we introduced in Exercise 3.2.48, can be used to compute QR decompositions of non-square matrices. (e Try out the following commands, for example Evercise 3.3.10 n6 m3 A-randn (n, m) (Q, R] qr (A) norm (eye (n)-' *Q) norm (A-Q*R) In the interest of convenience, MATLAB returns Q in assembled form. Write a short MATLAB script (m-file) that solves least squares problems using the qr command. (The submatrix R can be accessed by writing R (1 :m, 1:m) or R (1:m, :), for example.) Use your script to work parts (a) and (b) of Exercise 3.3.9. This is not the simplest way to solve least squares problems using MATLAB. Recall from Exercise 3.1.5 that the command xAlb works as well. This gives you a simple way to check your work.Explanation / Answer
[Q,R] = qr(A)
U = R(1:3,1:3)
c = Q' * b
d = c(1:3)
x = UTriSol(U,d)
e = A*x - b
norm(e)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.