Is there a way to solve singular matrix on MATLAB

In summary, to find a general solution to a singular matrix, you can rearrange the matrix in reverse order and augment it, then calculate the Row Reduced Echelon Form to find the solutions for each variable.
  • #1
Dell
590
0
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
 
Physics news on Phys.org
  • #2
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).
 
  • #3


Yes, there are several ways to solve a singular matrix on MATLAB. One approach is to use the linsolve function, which can handle singular matrices by using a generalized inverse. The syntax for using linsolve in this case would be:

x = linsolve(A,b)

where A is the coefficient matrix and b is the right-hand side vector. This will give you a solution vector x that satisfies the equation Ax=b. However, it is important to note that this solution may not be unique and there may be an infinite number of solutions.

Another approach is to use the pinv function, which calculates the pseudoinverse of a matrix. This can be used to solve the equation Ax=b for a singular matrix A. The syntax for using pinv in this case would be:

x = pinv(A)*b

This will also give you a solution vector x that satisfies the equation Ax=b. Again, this solution may not be unique.

In terms of finding a general solution for a singular matrix, it is important to note that there may not be a unique solution and there may be an infinite number of solutions. In this case, you can use the null function to find the null space of the matrix A, which represents all possible solutions to the equation Ax=0. The syntax for using null in this case would be:

N = null(A)

This will give you a matrix N whose columns span the null space of A. You can then use this information to find a general solution to the equation Ax=b by adding any vector in the null space to a particular solution x0. For example, if x0 is a particular solution to Ax=b, then any vector in the null space N can be added to x0 to obtain another solution to the equation.

In summary, there are several ways to solve a singular matrix on MATLAB, including using the linsolve function, the pinv function, or finding the null space of the matrix. However, it is important to keep in mind that a singular matrix may not have a unique solution and there may be an infinite number of solutions.
 

Related to Is there a way to solve singular matrix on MATLAB

1. Can I use the inverse function to solve a singular matrix on MATLAB?

No, the inverse function cannot be used to solve a singular matrix on MATLAB. This is because a singular matrix does not have an inverse.

2. How can I identify if a matrix is singular on MATLAB?

You can use the "rank" function on MATLAB to determine the rank of the matrix. If the rank is less than the number of columns or rows, then the matrix is singular.

3. Can I use the "backslash" operator to solve a singular matrix on MATLAB?

Yes, the "backslash" operator can be used to solve a singular matrix on MATLAB. It uses a least squares method to find an approximate solution.

4. Are there any other methods for solving a singular matrix on MATLAB?

Yes, there are other methods such as the "pinv" function, which calculates the pseudo-inverse of a singular matrix, and the "linsolve" function, which uses LU decomposition to solve a system of linear equations.

5. Can I get an exact solution for a singular matrix on MATLAB?

No, an exact solution cannot be obtained for a singular matrix on MATLAB. This is because a singular matrix does not have a unique solution.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
905
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top