MATLAB 矩阵问题

发布于 2024-11-07 16:41:14 字数 642 浏览 0 评论 0原文

我有一个方程组(总共 5 个),有 5 个未知数。我已将它们放入矩阵中以尝试解决,但我不确定结果是否正确。基本上设置是 AX = B,其中 AXB 是矩阵。 A 是 5x5,X 是 1x5,B 是 5x1。

当我使用 MATLAB 使用公式 X = A\B 求解 X 时,它会向我发出警告:

Matrix is singular to working precision.

并为所有 5 个 X 未知数给出 0,但如果我说 X = B\A 事实并非如此,并给出了 5 个 X 未知数的值。

有人知道我做错了什么吗?如果这很重要,这就是我的 X 矩阵的样子:

X= [1/C3; 1/P1; 1/P2; 1/P3; 1/P4]

其中 C3P1P2P3P4 是我的未知数。

I have a system of equations (5 in total) with 5 unknowns. I've set these out into matrices to try solve, but I'm not sure if this comes out right. Basically the setup is AX = B, where A,X, and B are matrices. A is a 5x5, X is a 1x5 and B is a 5x1.

When I use MATLAB to solve for X using the formula X = A\B, it gives me a warning:

Matrix is singular to working precision.

and gives me 0 for all 5 X unknowns, but if I say X = B\A it doesnt, and gives me values for the 5 X unknowns.

Anyone know what I'm doing wrong? In case this is important, this is what my X matrix looks like:

X= [1/C3; 1/P1; 1/P2; 1/P3; 1/P4]

Where C3, P1, P2, P3, P4 are my unknowns.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

冰雪之触 2024-11-14 16:41:14

您的矩阵是奇异,这意味着它的行列式为 0。这样的方程组无法为您提供足够的信息来找到唯一的解决方案。我在你的问题中看到的一件奇怪的事情是 X 是 1x5,而 B 是 5x1。这不是提出问题的正确方式。 XB 都必须为 5x1。如果您想知道,这不是 Matlab 的东西 - 这是线性代数的东西。此 [5x5]*[1x5] 是非法的。此 [5x5]*[5x1] 生成 [5x1] 结果。此 [1x5]*[5x5] 生成 [1x5] 结果。首先检查代数,然后检查行列式(Matlab 中的det 函数)是否为 0。

Your matrix is singular, which means its determinant is 0. Such system of equations does not give you enough information to find a unique solution. One odd thing I see in your question is that X is 1x5 while B is 5x1. This is not a correct way of posing the problem. Both X and B must be 5x1. In case you're wondering, this is not a Matlab thing - this is a linear algebra thing. This [5x5]*[1x5] is illegal. This [5x5]*[5x1] produces a [5x1] result. This [1x5]*[5x5] produces a [1x5] result. Check you algebra first, and then check whether the determinant (det function in Matlab) is 0.

留蓝 2024-11-14 16:41:14

所以,接下来的事情就是弄清楚为什么 A 是单数。 (请注意,在具有平方和单数 A 的情况下,您可能想要求解

A x = b

,但仅在 bA 的范围空间内。)

也许你可以写出你的矩阵 A 和向量 b (因为它只是5x5)?或者解释一下你是如何创建它的。这可能会提供一些线索,说明为什么 A 未满秩,或者为什么 b 不在 A 的范围空间中。

So, the next thing is to figure out why A is singular. (Note that it's possible that you'd want to solve

A x = b

in cases with square and singular A, but they'd only be in cases where b is in the range space of A.)

Maybe you can write your matrix A and vector b out (since it's only 5x5)? Or explain how you create it. That might give a clue as to why A isn't full rank or as to why b isn't in the range space of A.

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