A = zeros(3)
A =
     0     0     0
     0     0     0
     0     0     0
A(:) = 1:9
A =
     1     4     7
     2     5     8
     3     6     9
home;
A(7)
ans =
     7
A(2,:)
ans =
     2     5     8
A(:,3)
ans =
     7
     8
     9
rref(A)
ans =
     1     0    -1
     0     1     2
     0     0     0
A
A =
     1     4     7
     2     5     8
     3     6     9

home
b = [3;2;2]
b =
     3
     2
     2
rref([A,b])
ans =
     1     0    -1     0
     0     1     2     0
     0     0     0     1

b1  = A * rand(3,1); 
b1
b1 =
    5.3268
    7.1743
    9.0218
rref([A,b1])
ans =
    1.0000         0   -1.0000    0.6877
         0    1.0000    2.0000    1.1598
         0         0         0         0
home
rref([A,b1])
ans =
    1.0000         0   -1.0000    0.6877
         0    1.0000    2.0000    1.1598
         0         0         0         0

A2 =  A(:,1:2)
A2 =
     1     4
     2     5
     3     6
disp('das ist EINE basis f.d. Spaltenraum');
das ist EINE basis f.d. Spaltenraum
help gramsfei
  GRAMSFEI.M	- Gram-Schmidt orthogonalization.
 
  Input		: A = matrix
 
  Output	: Q = matrix with orthonormal columns 
                  R = upper triangular matrix
 
  Usage		: [Q,R] = gramsfei(A);
 
  Comments	: This algorithm is numerically unstable.


OA2 = gramsfei(A2)
OA2 =
    0.2673    0.8729
    0.5345    0.2182
    0.8018   -0.4364
home
ans
ans =
    1.0000         0   -1.0000    0.6877
         0    1.0000    2.0000    1.1598
         0         0         0         0
OA2 = gramsfei(A2)
OA2 =
    0.2673    0.8729
    0.5345    0.2182
    0.8018   -0.4364
norm( b1 -   OA2 * OA2' *b1)
ans =
  6.6465e-015
PA = OA2*OA2'
PA =
    0.8333    0.3333   -0.1667
    0.3333    0.3333    0.3333
   -0.1667    0.3333    0.8333
home
norm( PA*PA - PA)
ans =
  5.2377e-016
norm( PA * A - A)
ans =
  7.7352e-015
eps
ans =
  2.2204e-016
OA = orth(A)
OA =
   -0.4797    0.7767
   -0.5724    0.0757
   -0.6651   -0.6253
OA2
OA2 =
    0.2673    0.8729
    0.5345    0.2182
    0.8018   -0.4364
home
norm(OA*OA' - PA)
ans =
  6.9492e-016
PINVA = pinv(A)
PINVA =
   -0.6389   -0.0556    0.5278
   -0.1667   -0.0000    0.1667
    0.3056    0.0556   -0.1944
norm(  A * PINVA - PA)
ans =
  1.0961e-015
A2
A2 =
     1     4
     2     5
     3     6
B2 = pinv(A2')
B2 =
   -0.9444    0.4444
   -0.1111    0.1111
    0.7222   -0.2222
home
pinv(A2)'
ans =
   -0.9444    0.4444
   -0.1111    0.1111
    0.7222   -0.2222
B2' * A2
ans =
    1.0000    0.0000
    0.0000    1.0000

A2
A2 =
     1     4
     2     5
     3     6
B2
B2 =
   -0.9444    0.4444
   -0.1111    0.1111
    0.7222   -0.2222
home
norm(PA - A2 * B2')
ans =
  2.0485e-015
norm(PA - B2 * A2')
ans =
  2.0485e-015
PZ =    pinv(A) *  A
PZ =
    0.8333    0.3333   -0.1667
    0.3333    0.3333    0.3333
   -0.1667    0.3333    0.8333
rank(PZ)
ans =
     2
norm( PZ * PZ - PZ)
ans =
  7.9585e-016
A
A =
     1     4     7
     2     5     8
     3     6     9

home
A'
ans =
     1     2     3
     4     5     6
     7     8     9
PZ * A'
ans =
    1.0000    2.0000    3.0000
    4.0000    5.0000    6.0000
    7.0000    8.0000    9.0000
diary off;
