MATLAB 求解方程问题
我想使用 MATLAB 求解这些方程,并且我确信是一个非零解。等式为:
0.7071*x + 0.7071*z = x
-0.5*x + 0.7071*y + 0.5*z = y
-0.5*x - 0.7071*y + 0.5*z = z
我在 MATLAB 中写道:
[x,y,z]=solve('0.7071 * x+0.7071 * z=x','-0.5 * x+0.7071 * y+0.5 * z=y','-0.5 * x-0.7071 * y+0.5 * z=z');
但结果是 x = y = z = 0。 正如我所说,我确信有解决方案。有人可以帮忙吗?
I want to solve these equations using MATLAB and I am sure there is a non zero solution. The equations are:
0.7071*x + 0.7071*z = x
-0.5*x + 0.7071*y + 0.5*z = y
-0.5*x - 0.7071*y + 0.5*z = z
I wrote in MATLAB:
[x,y,z]=solve('0.7071 * x+0.7071 * z=x','-0.5 * x+0.7071 * y+0.5 * z=y','-0.5 * x-0.7071 * y+0.5 * z=z');
But the result is x = y = z = 0.
As I said I am sure that there is a solution. Can any one help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您正在寻找一个非平凡的解决方案 v 到 A*v=v 且 v=[x;y;z] 并且...
您可以将其转换为 (AI)v=0,其中 I 是 3x3 单位矩阵。要找到一个不平凡的解决方案,你必须做的是检查人工智能的零空间:
所以,你有一个一维零空间。否则您会看到不止一列。列的每个线性组合都是该零空间中的一个点,AI 将其映射到零向量。因此,该向量的每个倍数都是您问题的解决方案。
实际上,你的矩阵 A 是第一类旋转矩阵,因为 det(A)=1 且 A'*A=identity。因此它的特征值为1,以旋转轴为对应的特征向量。我上面计算的向量是标准化旋转轴。
注意:为此,我用 sqrt(0.5) 替换了您的 0.7071。如果舍入误差是一个问题,但你事先知道必须有一个不平凡的解决方案,最好的选择是对 AI 进行奇异值分解并选择最右边的奇异向量:
这样你就可以计算一个向量 v 来最小化|A*vv|在 |v|=1 的约束下,其中 |.|是欧几里得范数。
You're looking for a non-trivial solution v to A*v=v with v=[x;y;z] and...
You can transform this into (A-I)v=0 where I is the 3x3 identity matrix. What you have to do to find a nontrivial solution is checking the null space of A-I:
So, you have a onedimensional nullspace. Otherwise you'd see more than one column. Every linear combination of the columns is a point in this null space that A-I maps to the null vector. So, every multiple of this vector is a solution to your problem.
Actually, your matrix A is a rotation matrix of the first kind because det(A)=1 and A'*A=identity. So it has an eigenvalue of 1 with the rotation axis as corresponding eigenvector. The vector I computed above is the normalized rotation axis.
Note: For this I replaced your 0.7071 with sqrt(0.5). If rounding errors are a concern but you know in advance that there has to be a nontrivial solution the best bet is to do a singular value decomposition of A-I and pick the right most right singular vector:
This way you can calculate a vector v that minimizes |A*v-v| under the constraint that |v|=1 where |.| is the Euclidean norm.
我认为您不需要使用
solve
函数,因为您的方程是线性方程组。重新转换为矩阵方程:
在您的情况下:
使用 MATLAB 的内置函数来求解。请参阅MATLAB:线性方程组的解。
MATLAB的核心就是求解这类方程。
使用 FreeMat (一个类似 MATLAB 的开源环境,
GPL 许可证; Windows 安装程序的直接下载 URL):
所以解为: x = 0, y = 0, z = 0
该解也可以手动导出。从最后两个方程开始:
因此 y = 0.0 并且:
插入第一个方程:
因此 x = 0.0。当 x = z 时,z = 0.0。
I don't think you need to use the
solve
function as your equations is a system of linear equations.Recast as a matrix equation:
In your case:
Use the built-in functionally of MATLAB to solve it. See e.g. MATLAB: Solution of Linear Systems of Equations.
The core of MATLAB is to solve this kind of equation.
Using FreeMat (an open-source MATLAB-like environment with
a GPL license; direct download URL for Windows installer):
So the solution is: x = 0, y = 0, z = 0
The solution can also be derived by hand. Starting from the last two equations:
Thus y = 0.0 and:
Inserting in the first equation:
Thus x = 0.0. And as x = z, then z = 0.0.
x = 0、y = 0、z = 0 是正确的解。这个问题可以通过手工轻松解决。
x = 0, y = 0, z = 0 is the correct solution. This problem can be easily worked by hand.
朋友们使用MATLAB命令rref(A) for Ax=B....它将给出一个上三角矩阵。然后你可以轻松计算非平凡的解决方案......但请记住,如果 rref(A)=I (如您的情况),那么非平凡的解决方案不存在。
祝你好运
Friends use MATLAB command rref(A) for Ax=B.... It will give a upper triangular Matrix. Then u can calculate non-trivial solutions easily... But keep in mind that if rref(A)=I (as in your case) then non-trivial solutions do not exist.
BEST OF LUCK