MATLAB Lecture 2 School of Mathematical Sciences Xiamen University http∥gdjpkc.xmu.edu.cr ular Coefficient Matrix If A is singular, the solution to AX=B either does not exist, or is not unique. The backslash operator, AB, issues a warning if A is nearly singular and raises an error condition if it detects exact singularity. If A is singular and AX-b has a solution, you can find a particular solution that is not unique typing >> P= pinv(A)b pinv(A)is a Moore-Penrose pseudoinverse of A. The Moore-Penrose pseudoinverse is a matrix B of the same dimensions as a satisfying four conditions A*BA=A B*A*B=B A*B is Hermitian B*A is Hermitian The computation is based on svd(a) If Ax =b does not have an exact solution, pinv(A)returns a least-squares solution. PInV(A=(A'A)A' For example, 1018 is singular, as you can verify by typing ans Exact Solutions For b=[5: 2: 12, the equation AX-b has an exact solution, given by ans 0.3850 -0.1103 0.7066 You can verify that pinv(a)"b is an exact solution by typing >>A'pinv(A)"b Lec2-3MATLAB Lecture 2 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec23 10 12 5 Singular Coefficient Matrix If A is singular, the solution to AX = B either does not exist, or is not unique. The backslash operator, A\B, issues a warning if A is nearly singular and raises an error condition if it detects exact singularity. If A is singular and AX = b has a solution, you can find a particular solution that is not unique, by typing >> P = pinv(A)*b pinv(A) is a MoorePenrose pseudoinverse of A. The MoorePenrose pseudoinverse is a matrix B of the same dimensions as A' satisfying four conditions: A*B*A = A B*A*B = B A*B is Hermitian B*A is Hermitian The computation is based on svd(A). If AX = b does not have an exact solution, pinv(A) returns a leastsquares solution. pinv(A)=(A’A) 1A’ For example, >> A = [ 1 3 7 1 4 4 1 10 18 ] is singular, as you can verify by typing >> det(A) ans = 0 Exact Solutions. For b =[5;2;12], the equation AX = b has an exact solution, given by >> pinv(A)*b ans = 0.3850 0.1103 0.7066 You can verify that pinv(A)*b is an exact solution by typing >> A*pinv(A)*b ans =