General Comments:
All matrix commands must be placed between the command "MATRIX." and "END MATRIX".
The source of all wisdom on SPSS matrix algebra is the Advanced Statistics 6.1 Reference Manual. The relevant pages are 468 to 512.
To write a matrix, enclose the elements of the matrix within braces ({}). Elements of each row are separated by commas. (The number of columns is implied by the number of elements in each row.) Rows are separated by semi-colons. Thus {2,4,3,7;1,5,3,1} is a 2 x 4 matrix that looks like
2 4 3 7
1 5 3 1
Matrices can be defined explicitly as above or read into the MATRIX processor using a READ or GET command. For example if the above matrix was created using a word processor and saved as an ASCII or TXT file with the name "MATRIX1.DAT" it can be read with the following command:
READ A /FILE=MATRIX1.DAT /FIELD = 1 to #.
Manipulating Matrices
COMPUTE C = {A,B}. Concatenate (Join) A and B vertically where A and B are matrices or vectors. (A & B must have the same number of rows.)
COMPUTE C = {A;B}. Concatenate (Join) A and B horizontally where A and B are matrices or vectors. (A & B must have the same number of columns.)
COMPUTE A = MAKE (#1, #2, #3). Create #1 by #2 rectangular matrix with value #3 in all elements.
COMPUTE I = IDENT (#1). Create a square identity matrix with #1 rows/columns.
COMPUTE A = MDIAG (#1) Create square matrix with values of vector V as main diagonal, elsewhere 0
COMPUTE NR = NROW (A). Finds # of rows in A.
COMPUTE NC = NCOL (A). Finds # of columns in A.
Key Matrix Operators
COMPUTE C = A + B. Add matrices A and B.
COMPUTE C = A * B. Multiply matrices A and B.
COMPUTE AT = T (A). Find the transpose of A.
COMPUTE INVA = INV (A). Calculate the inverse of A.
COMPUTE DETA = DET (A) Calculate the determinant of A.
COMPUTE DIAGA = DIAG (A). Create a column vector from the diagonal of matrix A.
COMPUTE EIGA = EVAL (A) Compute the eigenvalues of A and place in column vector.
COMPUTE RANKA = RANK (A). Assess the rank of A.
Results
PRINT A /FORMAT = F10.4 / TITLE = "My Results".