function B = gs(A)
% B's columns are the orthogonal vectors computed so far.
% Subtract the appropriate multiple of of v from x
% Append x to B
% divide B's j-th column by it's length
What's going on with "for u=A"? Okay... I assume you've seen "for n=1:5" for the standard "for" loop. What is "1:5"? Go to the MATLAB command line and type "1:5". What do you get? [1 2 3 4 5]. "1:5" is actually a vector. The each trip thru the loop sets n to the next entry in this vector. Now try typing this at the command line (the loop won't execute until you type "end")...
for n=[1 2 4 7 -2 0.5]
The "n" in the middle just prints the current value of n, which is each of the given values, in turn. More generally, "for u=A" sets u equal to a new column of A on each trip thru the loop. So "for u=A" can be used to process one column of A at a time, without worring about an artificial indexing variable like "i". The next for loop "for v=B" is doing the same thing... we want to subtract a multiple of each column of B from x, and this for loop handles moving thru these columns.