function U = gs(A) %GS Gram-Schmidt process on the columns of A. % Uses the Gram-Schmidt process to construct a matrix U whose columns % form an orthogonal basis for the column space of the matrix A. The % columns of A need not be linearly independent. At the end, you are % given the option to have normalized columns in U. % % Format: U = gs(A) % Written by David Lay, University of Maryland, College Park % Version: 8/3/93 %(c) David C. Lay, 1993 % Updated 7/31/2002 [m n] = size(A); col = 1; while (col