Can someone help with this code to solve the Linear Algera problem?
Show older comments
For each system of linear algebraic equations,determine if the system is underdetermined, has an exactsolution, or is overdetermined. If the system is underdetermined, find the general solution using the RREF function and then find a particular solution and check your answer. If the system is exact,find the unique solution and check your answer.If the system is overdetermined, find a least squares solution.
a)
x1-x2+x3-x4=3
3x1+2x2-4x3+x4=2
-x1+5x2+2x3+3x4=4
4x1+x2-3x3=5
b)
x1-x2+x3-x4=3
3x1+2x2-4x3+x4=2
-x1+5x2+2x3+3x4=4
4x1+x2-3x3+2x4=-1
c)
x1-x2+x3-x4=3
3x1+2x2-4x3+x4=2
-x1+5x2+2x3+3x4=4
4x1+x2-3x3=7
2 Comments
James Tursa
on 26 Apr 2018
What have you done so far? What specific problems are you having with your code?
Soren Carpenter
on 26 Apr 2018
Answers (1)
Start with converting the equations to one matrix equation:
x1-x2+x3-x4=3
3x1+2x2-4x3+x4=2
-x1+5x2+2x3+3x4=4
4x1+x2-3x3=5
To:
A = [1, -1, 1, -1; ...
3, 2, -4, 1; ...
-1, 5, 2, 3; ...
4, 1, -3, 0];
b = [3; 2; 4; 5]
Now you want to solve:
A*x = b
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!