Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Group: Matrix Manipulation
Topic: General Commands
See also: matrix unit

Function: diag
Description: diag creates a diagonal matrix from a vector.

Usage: z = diag (x)
Input:
x p x 1 matrix
Output:
z p x p diagonal matrix

Example:
diag(1:4)

Result:
Contents of diag
[1,]        1        0        0        0
[2,]        0        2        0        0
[3,]        0        0        3        0
[4,]        0        0        0        4



(C) MD*TECH Method and Data Technologies, 05.02.2006