imat_fn/diag


Purpose

Diagonal IMAT_FN matrices and diagonal of a matrix.

Syntax

g=diag(f)
g=diag(f,k)

Description

DIAG implements the MATLAB DIAG function for IMAT_FN.

diag(F,K) when F is an IMAT_FN vector with N components is a square matrix of order N+ABS(K) with the elements of V on the K-th diagonal. K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0 is below the main diagonal.

diag(V) is the same as diag(V,0) and puts V on the main diagonal.

diag(X,K) when X is an IMAT_FN matrix is an IMAT_FN column vector formed from the elements of the K-th diagonal of X.

diag(X) is the main diagonal of X. diag(diag(X)) is a diagonal matrix.