a
a =
    0.0469
    0.4575
    0.4649
   -0.3424
bas = -3 : 0.01: 3;
plot(bas, polyval(a,bas));
figue(gcf);
??? Undefined function or method 'figue' for input arguments of type 'double'.

figure(gcf);

[xx, yy ] =  ginput(9);

xx
xx =
   -2.7145
   -1.7661
   -1.1081
   -0.1500
    0.7984
    1.7661
    2.3371
   -2.3371
    2.8500
yy
yy =
    0.8426
    0.0463
   -0.2315
   -0.4722
    0.4537
    2.0833
    3.9907
    0.3981
    5.9537

hold; 
Current plot held
plot(xx,yy,'r*');
type
??? Error using ==> type
Not enough input arguments.

type shg

%   SHG.M    HGFei, 1998:   just replacement of  "figure(gcf)" 
% 

figure(gcf);  


gcf
ans =
     3
shg

xx4 =  xx(2:5)
xx4 =
   -1.7661
   -1.1081
   -0.1500
    0.7984
vander(xx4)
ans =
   -5.5089    3.1192   -1.7661    1.0000
   -1.3605    1.2278   -1.1081    1.0000
   -0.0034    0.0225   -0.1500    1.0000
    0.5089    0.6374    0.7984    1.0000
V4 = ans; det(V4)
ans =
    4.7245
cond(V4)
ans =
   16.9109

a4 =  inv(V4) * yy(2:5);
a4
a4 =
    0.2099
    0.7404
    0.3829
   -0.4307
a
a =
    0.0469
    0.4575
    0.4649
   -0.3424
plot(bas, polyval(a4,bas),'g');
shg

V9 = vander(xx);
size(V9)
ans =
     9     9
V49 =  V9(:,6:9)
V49 =
  -20.0022    7.3686   -2.7145    1.0000
   -5.5089    3.1192   -1.7661    1.0000
   -1.3605    1.2278   -1.1081    1.0000
   -0.0034    0.0225   -0.1500    1.0000
    0.5089    0.6374    0.7984    1.0000
    5.5089    3.1192    1.7661    1.0000
   12.7653    5.4620    2.3371    1.0000
  -12.7653    5.4620   -2.3371    1.0000
   23.1491    8.1225    2.8500    1.0000

apinv =  pinv(V49) * yy;
plot(bas, polyval(apinv,bas),'k*');
shg

plot(bas, polyval(apinv,bas),'w*');
shg

plot(bas, polyval(a,bas),'b*');
plot(bas, polyval(a,bas),'w*');
plot(bas, polyval(a,bas),'b');
shg

plot(bas, polyval(apinv,bas),'k');
shg
plot(xx,yy,'r*');
shg

grid;
shg
save  polint49a

A = rand(4,7); B= rand(5,4);
C =  B*A;
size(C)
ans =
     5     7
rank(C)
ans =
     4
NC = null(C)
NC =
   -0.4590   -0.1590   -0.4003
   -0.0052    0.1044   -0.3212
    0.3821    0.1794   -0.4804
    0.4213   -0.0671    0.3799
    0.3147   -0.5438    0.2747
    0.2710    0.7485    0.1233
   -0.5416    0.2666    0.5204
PN =  NC * NC';
PN
PN =
    0.3962    0.1144   -0.0116   -0.3348   -0.1680   -0.2927   -0.0021
    0.1144    0.1141    0.1711   -0.1313   -0.1467    0.0372   -0.1365
   -0.0116    0.1711    0.4089   -0.0336   -0.1093    0.1786   -0.4091
   -0.3348   -0.1313   -0.0336    0.3264    0.2735    0.1108   -0.0484
   -0.1680   -0.1467   -0.1093    0.2735    0.4703   -0.2880   -0.1725
   -0.2927    0.0372    0.1786    0.1108   -0.2880    0.6489    0.1170
   -0.0021   -0.1365   -0.4091   -0.0484   -0.1725    0.1170    0.6351
norm( PN * PN - PN)
ans =
  2.5895e-016
PN * C' 
ans =
  1.0e-015 *
   -0.1052   -0.0976   -0.0533   -0.2164   -0.1657
   -0.0278   -0.0555   -0.0278   -0.1388    0.0555
   -0.0555         0         0         0         0
    0.1110    0.0278   -0.0694    0.1943   -0.0833
   -0.0278   -0.1665   -0.1665   -0.0555   -0.0555
    0.0625    0.1110   -0.0278    0.2498    0.1110
    0.0555    0.1110   -0.2220         0         0

OZ =  orth(C')
OZ =
   -0.4898    0.1366    0.4351    0.3949
   -0.3363   -0.8026   -0.3567   -0.0360
   -0.3888    0.5047   -0.2547   -0.3468
   -0.4695   -0.2073    0.5705   -0.2912
   -0.2962    0.1106   -0.4307    0.4942
   -0.0689    0.0238    0.0566    0.5853
   -0.4278    0.1629   -0.3232   -0.2255
POZ = OZ * OZ';
POZ+ PN
ans =
    1.0000   -0.0000    0.0000    0.0000   -0.0000   -0.0000    0.0000
   -0.0000    1.0000    0.0000    0.0000   -0.0000   -0.0000    0.0000
    0.0000    0.0000    1.0000   -0.0000   -0.0000   -0.0000   -0.0000
    0.0000    0.0000   -0.0000    1.0000    0.0000    0.0000   -0.0000
   -0.0000   -0.0000   -0.0000    0.0000    1.0000    0.0000    0.0000
   -0.0000   -0.0000   -0.0000    0.0000    0.0000    1.0000    0.0000
    0.0000    0.0000   -0.0000   -0.0000    0.0000    0.0000    1.0000
home
norm( POZ -  pinv(C) * C)
ans =
  8.1241e-014
OC = orth(C)
OC =
   -0.1902   -0.7366    0.3147    0.4627
   -0.3819    0.1275   -0.1450    0.6152
   -0.5360   -0.3662   -0.6595   -0.3776
   -0.5087   -0.0025    0.6668   -0.4644
   -0.5214    0.5541    0.0189    0.2219
OSC =  OC * OC';
norm(OSC * OSC - OSC)
ans =
  4.4843e-016
norm( OSC * C  - C)
ans =
  2.3220e-015
norm( OSC -  pinv(C)*C) 
??? Error using ==> minus
Matrix dimensions must agree.

norm( OSC -  C*pinv(C))
ans =
  1.5622e-014
home
size(C)
ans =
     5     7
y = rand(5,1);
ya = pinv(C) * y;
size(ya)
ans =
     7     1
norm( ya -  OZ*ya)
??? Error using ==> mtimes
Inner matrix dimensions must agree.

norm( ya -  POZ*ya)
ans =
  5.3302e-015

diary off;
