在Matlab中求解线性方程组的简单方法? [英] Simple way to solve a system of linear equations in Matlab?
问题描述
我正在寻找以下问题的简便解决方案:我具有三个3D矢量x_i
,三个3D矢量y_i
,一个3D矢量b
和一个系数为a11-a33的3x3矩阵A (未知).
I'm looking for an easy and fast solution to the following problem: I have three 3D vectors x_i
, three 3D vectors y_i
, a 3D vector b
and a 3x3 matrix A with coefficients a11 - a33 (that are unknown).
关系如下:
x_i = A * y_i + b
解决
x_i_1 = ( a11 * y_1_1 + a12 * y_2_1 + a13 * y_3_1 ) + b_1
等
因此,有9个方程式和9个未知变量a11-a33,简单易用的数学运算.但是我该如何使用Matlab中的内置函数来解决这个系统呢?
So there are 9 equations and 9 unknown variables a11 - a33, easy peasy math. But how do I solve this system using build in Matlab functions?
推荐答案
如果您知道9个方程式和9个未知数,则假装像9个未知数一样生活在名为r
的列向量中,并写出称为C
的9x9矩阵用于存储系数.如果9个方程式的左侧也存储在列向量x
中,那么您将要解决类似
If you know the 9 equations and 9 unknowns, then just pretend like the 9 unknowns live in a column vector called r
, and write the rows of a 9x9 matrix called C
to store the coefficients. If the left-hand side of the 9 equations is also stored in a column vector x
then you'll be solving something like
Cr = x
这在Matlab中只需完成
And this is simply done in Matlab with
r = C\x;
现在r
存储9个未知数的解决方案(假设存在解决方案,等等)
Now r
stores the solution for the 9 unknowns (assuming that solutions exist, etc.)
这篇关于在Matlab中求解线性方程组的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!