Understanding the Interactive Matrix Language |
Assignment statements create matrices by evaluating expressions and assigning the results to a matrix. The expressions can be composed of operators (for example, matrix multiplication) or functions (for example, matrix inversion) operating on matrices. Because of the nature of linear algebraic expressions, the resulting matrices automatically acquire appropriate characteristics and values. Assignment statements have the following general form:
a=sqrt(b);
The following statement calls the INV function to compute the inverse matrix of and assign the results to :
y=inv(x);
The following statement creates a matrix with elements that are the ranks of the corresponding elements of :
r=rank(x);
The three types of operators are as follows:
y=x#(x>0);This assignment statement creates a matrix in which each negative element of the matrix is replaced with zero. The statement actually has two expressions evaluated. The expression (>0) is a many-to-one operation that compares each element of to zero and creates a temporary matrix of results; an element of the temporary matrix is 1 when the corresponding element of is positive, and 0 otherwise. The original matrix is then multiplied elementwise by the temporary matrix, resulting in the matrix .
For a complete listing and explanation of operators, see Chapter 20.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.