正在加载图片...
MATLAB Lecture 2 School of Mathematical Sciences Xiamen University http∥gdjpkc.xmu.edu.cr >>Z=nul(R,r)% find an orthonormal basis(正交基) for the null space of R Z 7/6 It can be confirmed that R"Z is zero and that any vector x where > syms kl k2 k; Define three symbol variables >>k=[kl;k2] >>x=x0+Z*k %General solutions Column Full Rank Systems >>X=inv(A'A)A'b theoretically computes the same least squares solution x, although the backslash operator does it a does not have full rank x=Alb %a basic solution; it has at most r nonzero components, where r is the rank of A x= pinv(A)"b %the minimal norm solution because it minimizes norm(x X=inv(A'A)*A*b %fails because a"*A is singular >>A=fix(10°rand(3)) >>b=fix(10*rand(3,1)) > ABarA b > d=rref(ABar) %The last column of d is the solution of system d 119/48MATLAB Lecture 2  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu.cn  Lec2­5  >> Z = null(R,'r') % find an orthonormal basis (正交基) for the null space of R Z =  ­1/2  ­7/6  ­1/2  1/2  1  0  0  1  It can be confirmed that R*Z is zero and that any vector x where >> syms k1 k2 k;  % Define three symbol variables  >> k=[k1; k2];  >> x = x0 + Z*k  %General solutions  Column Full Rank Systems  >> x = A\b  >> x = pinv(A)*b  >> x = inv(A'*A)*A'*b  theoretically computes the same least squares solution x, although the backslash operator does it faster.  A does not have full rank  x = A\b  %a basic solution; it has at most r nonzero components, where r is the rank of A.  x = pinv(A)*b  %the minimal norm solution because it minimizes norm(x).  x = inv(A'*A)*A'*b  %fails because A'*A is singular. Example >> A=fix(10*rand(3));  >> b=fix(10*rand(3,1));  >> ABar=[A b];  >> d=rref(ABar) %The last column of d is the solution of system  d =  1  0  0  ­1/8  0  1  0  73/48  0  0  1  119/48
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有