A=[1, 0, 1; -1, 1, 1; -1, -1, 1]
A =
     1     0     1
    -1     1     1
    -1    -1     1
b
b =
     2
     1
    -1
b=[2;1,-1]
??? Error using ==> vertcat
All rows in the bracketed expression must have the same 
number of columns.

b=[2;1;-1]
b =
     2
     1
    -1
x=A\b
x =
     1
     1
     1
b-A*x
ans =
     0
     0
     0
x = hilb(15)\ones(15,1)
Warning: Matrix is close to singular or badly scaled.
         Results may be inaccurate. RCOND = 1.543404e-018.
x =
  1.0e+008 *
    0.0000
   -0.0000
    0.0007
   -0.0097
    0.0738
   -0.3122
    0.7102
   -0.5709
   -1.0953
    3.3002
   -2.9619
   -0.2353
    2.4214
   -1.7331
    0.4121
hilb(15)*x
ans =
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
    1.0000
format long
hilb(15)*x
ans =
   0.99999999720603
   1.00000000139698
   1.00000000372529
   1.00000000465661
   0.99999999674037
   0.99999999953434
   1.00000000232831
   0.99999999813735
   1.00000000512227
   0.99999999906868
   0.99999999930151
   1.00000000139698
   1.00000000069849
   1.00000000116415
   1.00000000442378
A = gallery('lauchli',3,0.25), b=[1,2,4,8]';
A =
   1.00000000000000   1.00000000000000   1.00000000000000
   0.25000000000000                  0                  0
                  0   0.25000000000000                  0
                  0                  0   0.25000000000000
format short
A = gallery('lauchli',3,0.25), b=[1,2,4,8]';
A =
    1.0000    1.0000    1.0000
    0.2500         0         0
         0    0.2500         0
         0         0    0.2500
x=A\b;
xn=lsqnoneg(A,b);
??? Undefined function or variable 'lsqnoneg'.

xn=lsqnonneg(A,b);
[x,xn], [norm(A*x-b) norm(A*xn-b)]
ans =
   -9.9592         0
   -1.9592         0
   14.0408    2.8235
ans =
    7.8571    8.7481
diary off
A = [1 1 1; 1 1 -1], b=[3; 1]
A =
     1     1     1
     1     1    -1
b =
     3
     1
x=A\b; y = pinv(A)*b;
[x y]
ans =
    2.0000    1.0000
         0    1.0000
    1.0000    1.0000
[norm(x) norm(y)]
ans =
    2.2361    1.7321
A=pascal(3), X=inv(A)
A =
     1     1     1
     1     2     3
     1     3     6
X =
     3    -3     1
    -3     5    -2
     1    -2     1
norm(A*X-eye(3))
ans =
     0
A=vander(1:5)
A =
     1     1     1     1     1
    16     8     4     2     1
    81    27     9     3     1
   256    64    16     4     1
   625   125    25     5     1
det(A)
ans =
   288
Y=pinv(ones(3))
Y =
    0.1111    0.1111    0.1111
    0.1111    0.1111    0.1111
    0.1111    0.1111    0.1111
Y*ones(3), ones(3)*Y
ans =
    0.3333    0.3333    0.3333
    0.3333    0.3333    0.3333
    0.3333    0.3333    0.3333
ans =
    0.3333    0.3333    0.3333
    0.3333    0.3333    0.3333
    0.3333    0.3333    0.3333
A=[0 0 0 0; 0 1 0 0; 0 0 2 0]
A =
     0     0     0     0
     0     1     0     0
     0     0     2     0
pinv(A)
ans =
         0         0         0
         0    1.0000         0
         0         0    0.5000
         0         0         0
format short g
A = gallery('fiedler',3), [L,U]=lu(A)
A =
     0     1     2
     1     0     1
     2     1     0
L =
            0            1            0
          0.5         -0.5            1
            1            0            0
U =
     2     1     0
     0     1     2
     0     0     2
A=pascal(4)
A =
     1     1     1     1
     1     2     3     4
     1     3     6    10
     1     4    10    20
R=chol(A)
R =
     1     1     1     1
     0     1     2     3
     0     0     1     3
     0     0     0     1
[R,p]=chol(A)
R =
     1     1     1     1
     0     1     2     3
     0     0     1     3
     0     0     0     1
p =
     0
format short e
A=[1 0 1; 1 -1 1; 2 0 0]
A =
     1     0     1
     1    -1     1
     2     0     0
[Q,R]=qr(A)
Q =
 -4.0825e-001  1.8257e-001 -8.9443e-001
 -4.0825e-001 -9.1287e-001 -5.5511e-017
 -8.1650e-001  3.6515e-001  4.4721e-001
R =
 -2.4495e+000  4.0825e-001 -8.1650e-001
            0  9.1287e-001 -7.3030e-001
            0            0 -8.9443e-001
A(2,2)=eps
A =
  1.0000e+000            0  1.0000e+000
  1.0000e+000  2.2204e-016  1.0000e+000
  2.0000e+000            0            0
[Q,R,P]=qr(A)
Q =
 -4.0825e-001 -5.7735e-001 -7.0711e-001
 -4.0825e-001 -5.7735e-001  7.0711e-001
 -8.1650e-001  5.7735e-001  5.5511e-017
R =
 -2.4495e+000 -8.1650e-001 -9.0649e-017
            0 -1.1547e+000 -1.2820e-016
            0            0  1.5701e-016
P =
     1     0     0
     0     0     1
     0     1     0
diary off
   C =
???    C =
          |
Error: Expected a variable, function, or constant, found "end of line".

C
??? Undefined function or variable 'C'.

C=[1 1; 1 2; 1 3]
C =
     1     1
     1     2
     1     3
[Q,R] = qr(C)
Q =
 -5.7735e-001  7.0711e-001  4.0825e-001
 -5.7735e-001  5.5511e-017 -8.1650e-001
 -5.7735e-001 -7.0711e-001  4.0825e-001
R =
 -1.7321e+000 -3.4641e+000
            0 -1.4142e+000
            0            0
[Q,R] = qr(C,0)
Q =
 -5.7735e-001  7.0711e-001
 -5.7735e-001  5.5511e-017
 -5.7735e-001 -7.0711e-001
R =
 -1.7321e+000 -3.4641e+000
            0 -1.4142e+000
C(2,2)=1+eps
C =
  1.0000e+000  1.0000e+000
  1.0000e+000  1.0000e+000
  1.0000e+000  3.0000e+000
diary off
[Q,R,P]=qr(C)
Q =
  -0.30151134457776  -0.63960214906683  -0.70710678118655
  -0.30151134457776  -0.63960214906683   0.70710678118655
  -0.90453403373329   0.42640143271122  -0.00000000000000
R =
  -3.31662479035540  -1.50755672288882
                  0  -0.85280286542244
                  0                  0
P =
     0     1
     1     0
format short
[Q,R,P]=qr(C)
Q =
   -0.3015   -0.6396   -0.7071
   -0.3015   -0.6396    0.7071
   -0.9045    0.4264   -0.0000
R =
   -3.3166   -1.5076
         0   -0.8528
         0         0
P =
     0     1
     1     0
[Q,R,p]=qr(C,0)
Q =
   -0.3015   -0.6396
   -0.3015   -0.6396
   -0.9045    0.4264
R =
   -3.3166   -1.5076
         0   -0.8528
p =
     2     1
diary off
