Solve linear equations in matrix form
X = linsolve(A,B)
[X,R] = linsolve(A,B)
Solve this system of linear equations in matrix form by using
A = [ 2 1 1; -1 1 -1; 1 2 3]; B = [2; 3; -10]; X = linsolve(A,B)
X = 3 1 -5
X, x = 3, y = 1 and z = -5.
Compute the reciprocal of the condition number of the square coefficient matrix by using two output arguments.
syms a x y z A = [a 0 0; 0 a 0; 0 0 1]; B = [x; y; z]; [X, R] = linsolve(A, B)
X = x/a y/a z R = 1/(max(abs(a), 1)*max(1/abs(a), 1))
If the coefficient matrix is rectangular,
returns the rank of the coefficient matrix as the second output argument.
syms a b x y A = [a 0 1; 1 b 0]; B = [x; y]; [X, R] = linsolve(A, B)
Warning: Solution is not unique because the system is rank-deficient. In sym.linsolve at 67 X = x/a -(x - a*y)/(a*b) 0 R = 2
A— Coefficient matrix
Coefficient matrix, specified as a symbolic matrix.
B— Right side of equations
Right side of equations, specified as a symbolic vector or matrix.
A system of linear equations
can be represented as the matrix equation , where A is the coefficient matrix:
and is the vector containing the right sides of equations:
If the solution is not unique,
a warning, chooses one solution and returns it.
If the system does not have a solution,
a warning and returns
X with all elements set
linsolve for numeric matrices
that are not symbolic objects invokes the MATLAB®
linsolve function. This function accepts
real arguments only. If your system of equations uses complex numbers,
sym to convert at least
one matrix to a symbolic matrix, and then call