matlab课程-第9讲_线性方程组求解-矩阵操作2011201.pptxVIP

  • 14
  • 0
  • 约3.86千字
  • 约 35页
  • 2017-05-27 发布于浙江
  • 举报

matlab课程-第9讲_线性方程组求解-矩阵操作2011201.pptx

matlab课程-第9讲_线性方程组求解-矩阵操作2011201

第9讲:Linear Algebra Functions;Creating Matrices;the Pascal matrix is an infinite matrix containing the binomial coefficients as its elements;Vector Products and Transpose-1;Vector Products and Transpose-2;Vector Products and Transpose-3;Vector Products and Transpose-4;Identity Matrix—单位矩阵;A=magic(3) B=[1, 2, 3; 0 1 2;2 5 8] rank(A) % 秩=[rank] ans = 3 det(A) %|A|≠0 Determinant of A rank(B) det(B) %(=0)? ; A’ % 转置矩阵 A+B %|A|≠0 Determinant of A A-B A*B % 矩阵相乘 B*A % A*B ≠B*A A^-1, inv(A) %逆矩阵 B^-1, inv(B) ; diag(A) % Diagonal matrices tril(A) % the lower triangular part of A triu(A) eig(A) % Eigenvalues of AX=λ X;线性方程求解:;Solving Linear Equations;2. Eg.?practise!A=?,B=?X=?; Solving with Matlab;奇异方阵;超定和欠定方程的概念;  【例】解下列线方程组:;方法一: 将其增广矩阵[A,b]。MATLAB中 rref命令。   ;方法二: x=inv(A)*b 方法三: x=A\b   ;  【例5-5-3】 在例5-5-2中,若把   第4个方程改为 4x1+2x2+7x3-778/222x4=877/222 求方程组的解。   解: 我们仍然用上题中的三种方法来解。 A=[6,1,6, -6; b=[7; 5; -7; 877/222]; 1, -1,9,9; -2,4,0, -4; 4,2,7,-778/222]; 方法一: U=rref([A,b]);以下为补充资料;【线形代数】特征值与特征向量;5.5.3 行列式的奇异性   【例5-5-7】 hilbert矩阵H具有如下规律,例如三阶hilbert矩阵H3: 它可由语句format rat, H3=hilb(3) 产生。现构成四元线性方程组 H4·x=b,   (1) 求H4的行列式D=det(H4)及条件数c=cond(H4);   (2) 设其中x为单位列向量,求b;   (3) 再按方程H4·x1=b求x1,并与x相比较,求出其最大相对误差(注意用长格式显示)。;  解: MATLAB程序如下: H4 = hilb(4), D =det(H4), c = cond(H4) x=ones(4,1); b = H4*x, %给定x为单位列向量,求b format long, x1 = H4\b, %由b求x1 e = max(abs(x1-x)./x) %检查x与x1的误差 H4 = 1.0000 0.5000 0.3333 0.2500   0.5000 0.3333 0.2500 0.2000   0.3333 0.2500 0.2000 0.1667   0.2500 0.2000 0.1667 0.1429 D = 1.6534e-007 c = 1.5514e+004; b4 = 2.0833 1.2833 0.9500 0.7595 x1 = 0.99999999999999 1.00000

文档评论(0)

1亿VIP精品文档

相关文档