1 / 9

用 MATLAB 软件 解线性方程组

用 MATLAB 软件 解线性方程组. MATLAB 提供了许多矩阵函数 . 正是因为拥有了为数众多的、完善的矩阵函数,才使得 MATLAB 具有了强大的功能。. 在命令窗口运行帮助命令 : help elmat , 可以列举出大量的矩阵函数. 下面是几个常用的矩阵函数 :. det 计算矩阵的行列式的值 inv 求矩阵的逆阵 [V D]=eig(A) 求矩阵 A 的特征值和特征向量 null(A,’r’) 给出齐次线性方程组 Ax=0 的基础解系 diag 取得矩阵对角线元素.

cyrah
Télécharger la présentation

用 MATLAB 软件 解线性方程组

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 用MATLAB软件解线性方程组

  2. MATLAB提供了许多矩阵函数. 正是因为拥有了为数众多的、完善的矩阵函数,才使得MATLAB具有了强大的功能。

  3. 在命令窗口运行帮助命令 :help elmat ,可以列举出大量的矩阵函数. 下面是几个常用的矩阵函数: det 计算矩阵的行列式的值 inv 求矩阵的逆阵 [V D]=eig(A)求矩阵A的特征值和特征向量 null(A,’r’) 给出齐次线性方程组Ax=0 的基础解系 diag 取得矩阵对角线元素

  4. 矩阵函数的应用 设矩阵 求A的行列式、秩和逆矩阵。 解: A=[3 -4 0; -1 5 2; 4 1 -6] det (A) %求矩阵的行列式的值 rank (A) %求矩阵的秩 inv (A) %求逆矩阵

  5. 解线性方程组 求线性方程组的唯一解 求线性方程组Ax=B的解,其中: 解法1 利用矩阵除法: X=A\B 解法2 利用求逆矩阵函数 inv:X1=inv(A)*B 比较:解法1比解法2更简便, 解法1 的算法优于解法2 , 解法1可用于一般矩阵,而解法2只能用于非奇异的方阵 因此,只需运用解法1 .

  6. 求线性方程组的通解 设 求线性方程组Ax=B的通解。

  7. 解法1: 利用除法 \ 在命令窗口输入以下命令: (注意:这里给出的 A不 是方阵) clc clear A=[1 1 -1 -1;2 -5 3 2;7 -7 3 1]; B=[5; -4; 7]; x1=A\B 输出结果: x1 = 3 2 0 0

  8. 解法2:利用 rref函数 在命令窗口输入以下命令: format ratA=[1 1 -1 -1;2 -5 3 2;7 -7 3 1]; B=[5; -4; 7];%用初等行变换将增广矩阵 [A B] 化成最简行阶梯形T T=rref([A B]) T = 1 0 -2/7 -3/7 3 0 1 -5/7 -4/7 2 0 0 0 0 0 输出结果:

  9. clc; clear; A=[12 -3 +3;-18 +3 -1;1 1 1]; B=[15; -15; 6]; x=A\B

More Related