| Symbolic Math Toolbox | ![]() |
Create or extract symbolic diagonals
Syntax
Description
diag(A,k), where A is a row or column vector with n components, returns a square symbolic matrix of order n+abs(k), with the elements of A on the k-th diagonal. k = 0 signifies the main diagonal; k > 0, the k-th diagonal above the main diagonal; k < 0, the k-th diagonal below the main diagonal.
diag(A,k), where A is a square symbolic matrix, returns a column vector formed from the elements of the k-th diagonal of A.
diag(A), where A is a vector with n components, returns an n-by-n diagonal matrix having A as its main diagonal.
diag(A), where A is a square symbolic matrix, returns the main diagonal of A.
Examples
Then both diag(v) and diag(v,0) return
See Also
| det | diff | ![]() |