inv
Inverse of symbolic matrix
Syntax
Description
Examples
Compute Inverse of Symbolic Matrix
Compute the inverse of a matrix of symbolic numbers.
A = sym([2 -1 0; -1 2 -1; 0 -1 2]); D = inv(A)
D =
Compute the inverse of a matrix of symbolic scalar variables.
symsabcdA = [a b; c d]; D = inv(A)
D =
Compute Inverse of Hilbert Matrix with Symbolic Numbers
Compute the inverse of the Hilbert matrix that contains symbolic numbers.
D = inv(sym(hilb(4)))
D =
Compute Inverse of Block Matrix
Find the inverse of a 4-by-4 block matrix
where and are 2-by-2 submatrices. The notation represents a 2-by-2 submatrix of zeros.
Use symbolic matrix variables to represent the submatrices in the block matrix.
symsAB[2 2]matrixZ = symmatrix(zeros(2))
Z =
C = [A Z; Z B]
C =
Find the inverse of the matrix 。
D = inv(C)
D =
To show the elements of the inverse matrix, convert the result from a symbolic matrix variable to symbolic scalar variables usingsymmatrix2sym
。
D1 = symmatrix2sym(D)
D1 =
Compute Inverse of Matrix Polynomial
Compute the inverse of the matrix polynomial , where is a 2-by-2 matrix.
Create the matrix
and the coefficients
,
, and
as symbolic matrix variables. Create the matrix polynomial as a symbolic matrix functionf
with
,
,
, and
as its parameters.
symsA[2 2]matrixsymsa0a1a2[1 1]matrixsymsf(A,a0,a1,a2)[2 2]matrixkeepargsf(A,a0,a1,a2) = a0*eye(2) + a1*A + a2*A^2
f(A, a0, a1, a2) =
Find the inverse off
usinginv
。The result is a symbolic matrix function of typesymfunmatrix
。
fInv = inv(f)
fInv(A, a0, a1, a2) =
Evaluate the inverse for the matrix value
and the coefficient values
,
, and
。The result is a symbolic matrix variable of typesymmatrix
。
Aval = [2 -1; -1 2]; fEval = fInv(Aval,-1,2,3)
fEval =
Convert the result from thesymmatrix
data type to thesym
data type usingsymmatrix2sym
。结果是一个矩阵的年代ymbolic numbers.
symmatrix2sym(fEval)
ans =
Input Arguments
A
—Input matrix
square numeric matrix|square matrix of symbolic scalar variables|square symbolic matrix variable|square symbolic matrix function|symbolic expression with square size
Input matrix, specified as a square numeric matrix, square matrix of symbolic scalar variables, square symbolic matrix variable, square symbolic matrix function, or symbolic expression with square size.
Data Types:single
|double
|sym
|symmatrix
|symfunmatrix
Tips
Matrix computations involving many symbolic variables can be slow. To increase the computational speed, reduce the number of symbolic variables by substituting the given values for some variables.
Version History
之前介绍过的R2006aR2022a: Compute inverse of symbolic matrix functions
Theinv
function accepts an input argument of typesymfunmatrix
。For an example, seeCompute Inverse of Matrix Polynomial。
R2021b: Compute inverse of symbolic matrix variables
Theinv
function accepts an input argument of typesymmatrix
。For an example, seeCompute Inverse of Block Matrix。
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(德语)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(德语)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)