Solving for a matrix

11 次查看(过去 30 天)
James Bader
James Bader 2018-10-29
评论: James Bader 2018-10-29
Hello all,
I have a matrix and need to invert it( Ax=b) and solve for x. However, I know one aspect of x and only need the others.
K = [7 -8 1 0 0 0 0; -8 16 -8 0 0 0 0; 1 -8 14 -8 1 0 0; 0 0 -8 16 -8 0 0; 0 0 1 -8 14 -8 1; 0 0 0 0 -8 16 -8; 0 0 0 0 1 -8 7];
syms f1 f2 f3 f4 f5 f6 f7 u1 u2 u3 u4 u5 u6 u7
F=[f1; f2; f3; f4; f5; f6; f7];
U=[u1; u2; u3; u4; u5; u6; u7];
eqn = F==K*U;
L = subs(eqn,[f1 f2 f3 f4 f5 f6 f7 u7], [0 0 0 0 0 0 -1 0])
This does give me the vector in terms of unknowns but doesn't actually solve for unknowns; is there a way to code it to do this? I tried U=K\F and it says the system is inconsistent however to my understanding I should be able to get numerical answers for each u aspect.
  2 个评论
Matt J
Matt J 2018-10-29
So why is this being done symbolically if you want numerical answers?
James Bader
James Bader 2018-10-29
I did not know another way to enter a system of equations with several unknown variables; it was recommended to me to use symbolic variables.

请先登录,再进行评论。

回答(1 个)

Bruno Luong
Bruno Luong 2018-10-29
编辑:Bruno Luong 2018-10-29
> K = [7 -8 1 0 0 0 0; -8 16 -8 0 0 0 0; 1 -8 14 -8 1 0 0; 0 0 -8 16 -8 0 0; 0 0 1 -8 14 -8 1; 0 0 0 0 -8 16 -8; 0 0 0 0 1 -8 7]
K =
7 -8 1 0 0 0 0
-8 16 -8 0 0 0 0
1 -8 14 -8 1 0 0
0 0 -8 16 -8 0 0
0 0 1 -8 14 -8 1
0 0 0 0 -8 16 -8
0 0 0 0 1 -8 7
>> cond(K)
ans =
2.7552e+16
>> rank(K)
ans =
6
>> size(K)
ans =
7 7
>>
Essentially that shows your linear system is ill-posed; meaning it either has no solution, and by chance it has (pick the right rhs) it has infinity number of solutions.

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by