@sym
: M =
diag (v)
¶@sym
: M =
diag (v, k)
¶@sym
: M =
diag (v, n, m)
¶@sym
: v =
diag (A)
¶@sym
: v =
diag (A, k)
¶Make diagonal matrix or extract diagonal of symbolic matrix.
Example:
A = sym([1 2 3; 4 5 6; 7 8 9]) ⇒ A = (sym 3×3 matrix) ⎡1 2 3⎤ ⎢ ⎥ ⎢4 5 6⎥ ⎢ ⎥ ⎣7 8 9⎦ v = diag(A) ⇒ v = (sym 3×1 matrix) ⎡1⎤ ⎢ ⎥ ⎢5⎥ ⎢ ⎥ ⎣9⎦
Make it back into a matrix:
diag(v) ⇒ (sym 3×3 matrix) ⎡1 0 0⎤ ⎢ ⎥ ⎢0 5 0⎥ ⎢ ⎥ ⎣0 0 9⎦
See also: @sym/repmat.
Package: symbolic