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 Comments

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

Sign in to comment.

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

Categories

Find more on Linear Algebra in Help Center and File Exchange

Asked:

on 26 Apr 2018

Edited:

Jan
on 26 Apr 2018

Community Treasure Hunt

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

Start Hunting!