MATLAB 求解方程问题

发布于 2024-08-10 22:05:02 字数 464 浏览 2 评论 0原文

我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

染墨丶若流云 2024-08-17 22:05:02

您正在寻找一个非平凡的解决方案 v 到 A*v=v 且 v=[x;y;z] 并且...

A =
   0.70710678118655                  0   0.70710678118655
  -0.50000000000000   0.70710678118655   0.50000000000000
  -0.50000000000000  -0.70710678118655   0.50000000000000

您可以将其转换为 (AI)v=0,其中 I 是 3x3 单位矩阵。要找到一个不平凡的解决方案,你必须做的是检查人工智能的零空间:

>> null(A-eye(3))

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

所以,你有一个一维零空间。否则您会看到不止一列。列的每个线性组合都是该零空间中的一个点,AI 将其映射到零向量。因此,该向量的每个倍数都是您问题的解决方案。

实际上,你的矩阵 A 是第一类旋转矩阵,因为 det(A)=1 且 A'*A=identity。因此它的特征值为1,以旋转轴为对应的特征向量。我上面计算的向量是标准化旋转轴。

注意:为此,我用 sqrt(0.5) 替换了您的 0.7071。如果舍入误差是一个问题,但你事先知道必须有一个不平凡的解决方案,最好的选择是对 AI 进行奇异值分解并选择最右边的奇异向量:

>> [u,s,v] = svd(A-eye(3));
>> v(:,end)

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

这样你就可以计算一个向量 v 来最小化|A*vv|在 |v|=1 的约束下,其中 |.|是欧几里得范数。

You're looking for a non-trivial solution v to A*v=v with v=[x;y;z] and...

A =
   0.70710678118655                  0   0.70710678118655
  -0.50000000000000   0.70710678118655   0.50000000000000
  -0.50000000000000  -0.70710678118655   0.50000000000000

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:

>> null(A-eye(3))

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

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:

>> [u,s,v] = svd(A-eye(3));
>> v(:,end)

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

This way you can calculate a vector v that minimizes |A*v-v| under the constraint that |v|=1 where |.| is the Euclidean norm.

雪花飘飘的天空 2024-08-17 22:05:02

我认为您不需要使用 solve 函数,因为您的方程是线性方程组。

重新转换为矩阵方程:

Ax = B

在您的情况下:

    | -0.2929   0.0      0.7071  |  | x |     | 0 |
    | -0.5     -0.2929   0.5     |  | y |  =  | 0 |
    | -0.5     -0.7071  -0.5     |  | z |     | 0 |

使用 MATLAB 的内置函数来求解。请参阅MATLAB:线性方程组的解

MATLAB的核心就是求解这类方程。


使用 FreeMat (一个类似 MATLAB 的开源环境,
GPL 许可证; Windows 安装程序的直接下载 URL):

   A = [ -0.2929 0.0 0.7071; -0.5 -0.2929 0.5; -0.5 -0.7071 -0.5 ]

   B = [0.0; 0.0; 0.0]

   A\B

   ans =
    0
    0
    0

所以解为: x = 0, y = 0, z = 0


该解也可以手动导出。从最后两个方程开始:

    -0.5*x + 0.7071*y +    0.5*z = y
    -0.5*x - 0.7071*y +    0.5*z = z

    0.2929*y =  -0.5*x + 0.5*z
    0.7071*y =  -0.5*x + 0.5*z

    0.2929*y = 0.7071*y

因此 y = 0.0 并且:

    0.7071*y =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0.5*x = 0.5*z

    x = z

插入第一个方程:

    0.7071*x + 0.7071*z = x 

    0.7071*x + 0.7071*x = x 

    1.4142*x = x 

因此 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:

Ax = B

In your case:

    | -0.2929   0.0      0.7071  |  | x |     | 0 |
    | -0.5     -0.2929   0.5     |  | y |  =  | 0 |
    | -0.5     -0.7071  -0.5     |  | z |     | 0 |

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):

   A = [ -0.2929 0.0 0.7071; -0.5 -0.2929 0.5; -0.5 -0.7071 -0.5 ]

   B = [0.0; 0.0; 0.0]

   A\B

   ans =
    0
    0
    0

So the solution is: x = 0, y = 0, z = 0


The solution can also be derived by hand. Starting from the last two equations:

    -0.5*x + 0.7071*y +    0.5*z = y
    -0.5*x - 0.7071*y +    0.5*z = z

    0.2929*y =  -0.5*x + 0.5*z
    0.7071*y =  -0.5*x + 0.5*z

    0.2929*y = 0.7071*y

Thus y = 0.0 and:

    0.7071*y =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0.5*x = 0.5*z

    x = z

Inserting in the first equation:

    0.7071*x + 0.7071*z = x 

    0.7071*x + 0.7071*x = x 

    1.4142*x = x 

Thus x = 0.0. And as x = z, then z = 0.0.

入画浅相思 2024-08-17 22:05:02

x = 0、y = 0、z = 0 是正确的解。这个问题可以通过手工轻松解决。

x = 0, y = 0, z = 0 is the correct solution. This problem can be easily worked by hand.

时光与爱终年不遇 2024-08-17 22:05:02
A = [ 0.7071 0 0.7071 ;
      -0.5 0.7071 0.5 ;
    -0.5 -0.7071 0.5 ];
B = [1 ; 1 ; 1];

AA = A-diag(B)

      -0.2929            0       0.7071
         -0.5      -0.2929          0.5
         -0.5      -0.7071         -0.5

BB = B-B

     0
     0
     0

AA\BB

     0
     0
     0
A = [ 0.7071 0 0.7071 ;
      -0.5 0.7071 0.5 ;
    -0.5 -0.7071 0.5 ];
B = [1 ; 1 ; 1];

AA = A-diag(B)

      -0.2929            0       0.7071
         -0.5      -0.2929          0.5
         -0.5      -0.7071         -0.5

BB = B-B

     0
     0
     0

AA\BB

     0
     0
     0
请持续率性 2024-08-17 22:05:02

朋友们使用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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文