Solving for a matrix
11 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Bruno Luong
on 29 Oct 2018
Edited: Bruno Luong
on 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.
0 Comments
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!