As discussed in §5.9.9, the orthogonal projection of onto is defined by
In matlab, the projection of the length-N column-vector y onto the length-N column-vector x may therefore be computed as follows:
yx = (x' * y) * (x' * x)^(-1) * xMore generally, a length-N column-vector y can be projected onto the -dimensional subspace spanned by the columns of the N M matrix X:
yX = X * (X' * X)^(-1) * X' * yOrthogonal projection, like any finite-dimensional linear operator, can be represented by a matrix. In this case, the matrix
PX = X * (X' * X)^(-1) * X'is called the projection matrix. I.2Subspace projection is an example in which the power of matrix linear algebra notation is evident.