Solving for a matrix

11 vues (au cours des 30 derniers jours)
James Bader
James Bader le 29 Oct 2018
Commenté : James Bader le 29 Oct 2018
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 commentaires
Matt J
Matt J le 29 Oct 2018
So why is this being done symbolically if you want numerical answers?
James Bader
James Bader le 29 Oct 2018
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.

Connectez-vous pour commenter.

Réponses (1)

Bruno Luong
Bruno Luong le 29 Oct 2018
Modifié(e) : Bruno Luong le 29 Oct 2018
> 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.

Community Treasure Hunt

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

Start Hunting!

Translated by