1. Consider the matrix: 3 x 3: [1 2 31 = A 3 3 4 567] Use the svd() function in MATLAB to compute A₁, the rank-1 approximation of A. Clearly state what A₁ is, rounded to 4 decimal places. Also, compute the root mean square error (RMSE) between A and A₁. 2. Use the svd() function in MATLAB to compute A₂, the rank-2 approximation of A. Clearly state what A₂ is, rounded to 4 decimal places. Also, compute the root mean square error (RMSE) between A and A₂. Which approximation is better, A₁ or A₂? Explain. 3. For the 3 x 3 matrix A, the singular value decomposition is AUSV' where U = [u₁₂ u3] Use MATLAB to compute the dot product d₁ = dot(u₁, u₂). Also, use MATLAB to compute the cross product c = cross(u₁, u2) and dot product d₂ = dot(c, u3). Clearly state the values for each of these computations. Do these values make sense? Explain.
Below is the answers to problem 1 and 2, please help with problem 3.
Problem 1
Use the svd() function in MATLAB to compute , the rank-1 approximation of . Clearly state what is, rounded to 4 decimal places. Also, compute the root-mean square error (RMSE) between and .
Solution:
%code
%Define matrix A
A = [1, 2, 3; 3, 3, 4; 5, 6, 7];
%Compute SVD of A
[U, S, V] = svd(A);
%Rank-1 approx
A1 = U(:,1) * S(1,1) * V(:,1)';
RMSE = sqrt(mean((A(:) - A1(:)).^2));
%Display A1 rounded to 4 decimal places
disp(round(A1, 4));
1.7039 2.0313 2.4935
2.7243 3.2477 3.9867
4.9087 5.8517 7.1832
%Display RMSE
disp(RMSE);
0.3257
Problem 2
Use the svd() function in MATLAB to compute , the rank-2 approximation of . Clearly state what is, rounded to 4 decimal places. Also, compute the root-mean square error (RMSE) between and . Which approximation is better, or ? Explain.
Solution:
%code
A = [2, 4, 7; 3, 3, 5; 1, 6, 6];
% Compute SVD of A
[U, S, V] = svd(A);
% Rank-2 approximation
A2 = U(:,1:2) * S(1:2,1:2) * V(:,1:2)';
% Round A2 to 4 decimal places
A2 = round(A2, 4);
% Display A2
disp(A2);
2.4486 4.3608 6.5949
2.6356 2.7069 5.3291
0.8347 5.8671 6.1493
% Compute RMSE between A and A2
RMSE = sqrt(mean((A(:) - A2(:)).^2));
disp(RMSE);
0.3144
Problem 3
Trending now
This is a popular solution!
Step by step
Solved in 2 steps