Can someone help with this code to solve the Linear Algera problem?

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 个评论

What have you done so far? What specific problems are you having with your code?
I am new to MATLAB and coding in general. How would I formulate the code? I understand how to solve the equations using linear algebra

请先登录,再进行评论。

回答(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
See: doc mldivide and doc rref. Try it and post specific question in case of further difficulties.

类别

在 帮助中心 和 File Exchange 中查找有关 Linear Algebra 的更多信息

编辑:

Jan
2018-4-26

Community Treasure Hunt

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

Start Hunting!

Translated by