在Matlab中建立线性方程组 [英] Setting up a system of linear equations in matlab

查看:320
本文介绍了在Matlab中建立线性方程组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要解决以下方程式:

H*b0 = M(Q+1)b(Q+1)+l+M'B

unknownsb0, b(q+1)B.已知矩阵的大小为:

The unknowns are b0, b(q+1) and B. The sizes of the known matrices are:

H=(42 x 42)

M(Q+1) = (42 x 21-P)

l = (42 x 1)

M' = (42 x 4)

所以我想弄清楚如何找到向量.

So I want to figure out how to find the vectors.

是否有内置命令可以执行此操作?

Is there a built in command that I could do to do this?

这来自本文

:未知数的大小应为(均为列向量):

: Size of unknowns should be (all are column vectors):

b0 = 21
b(q+1) = 21-P (P=4 in this case)
B = P (4 in this case)

推荐答案

首先,重新排列等式:

H b0 - M(Q+1) B(Q+1) - M' B = l

现在,您可以连接变量了.最终将得到大小为42 + 21 + 4 = 67的未知向量(X).大小为42 x 67

Now, you can concatenate variables. You will end up with an unknown vector (X) of size 42 + 21 + 4 = 67. And a coefficient matrix (A) of size 42 x 67

X = [b0;  B(Q+1);  B ];   % <- don't need to execute this; just shows alignment
A = [ H, -M(Q+1), -M'];

现在您有一个等式,形式为:

Now you have an equation of the form:

A X = l

现在,您可以使用\运算符以最小二乘的方式解决此问题:

Now you can solve this in a least-squares sense with the \ operator:

X = A \ l

可以使用上面的标识反过来将此X转换为b0B(Q+1)B:

This X can be turned back into b0, B(Q+1), and B using the identity above in reverse:

b0 = X(1:42);
B(Q+1) = X(43:63);
B = X(64:67);

这篇关于在Matlab中建立线性方程组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆