当前位置:网站首页>Solving linear equations with MATLAB ax=b

Solving linear equations with MATLAB ax=b

2022-06-24 08:48:00 Master Ma

Law 1: Left division

>> A=[3 1 -1;1 2 4;-1 4 5];B=[3.6;2.1;-1.4];

>> x=A\B

Output :
x =
1.4818
-0.4606
0.3848

Law 2: Inverse method

>> A=[3 1 -1;1 2 4;-1 4 5];b=[3.6;2.1;-1.4];

>> x=inv(A)*b

x2 =
1.4818
-0.4606
0.3848

Law 3: use linsolve Function solving

>> A=[3 1 -1;1 2 4;-1 4 5];b=[3.6;2.1;-1.4];

>> x=linsolve(A,b)

x3 =
1.4818
-0.4606
0.3848

Law 4: use solve Function solving

>> [x1 x2 x3]=solve('3*x1+x2-x3=3.6','x1+2*x2+4*x3=2.1','-x1+4*x2+5*x3=-1.4')

x1 =
1.4818181818181818181818181818182

x2 =

-0.46060606060606060606060606060606

x3 =

0.38484848484848484848484848484848

Law 5: Generalized inverse solution

>> A=[3 1 -1;1 2 4;-1 4 5];b=[3.6;2.1;-1.4];

>> x=pinv(A,b)

x4 =
1.4818
-0.4606
0.3848

原网站

版权声明
本文为[Master Ma]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240606048345.html