# Is there a way to solve singular matrix on MATLAB

if i have a matrix which i singular, and i need to find a general solution to it, is there a way to do this using linsolve or any other command,

for example, if i have

2x+y=5
x+z=2
3x+y+z=7

is there any way i can get a solution of
x=x
y=5-2x
z=2-x

Related Engineering and Comp Sci Homework Help News on Phys.org
The Electrician
Gold Member
Rearrange your matrix in reverse order:

Code:
  z y x
[ 0 1 2 ]
[ 1 0 1 ]
[ 1 1 3 ]
Then augment it:

Code:
  z y x
[ 0 1 2 5 ]
[ 1 0 1 2 ]
[ 1 1 3 7 ]
Then you need to calculate the Row Reduced Echelon Form:

Code:
  z y x
[ 1 0 1 2 ]
[ 0 1 2 5 ]
[ 0 0 0 0 ]
From this you can see that x=x (bottom row), and y = 5 - 2x (second row) and z = 2 - x (first row).