% residualanalys
  clear, clf
  T=(40:5:100)';
  p=[55 72 93 118 149 188 234 289 355 434 526 634 760]';
  A=[ones(13,1) T ]; c=A\p, r=p-A*c;  Fi1=r'*r
  X=(40:100)'; S=[ones(size(X)) X];  P=S*c;
  subplot(2,2,1); plot(T,p,'x', X,P), title('Gradtal 1')
  subplot(2,2,2); plot(T,r), title('Residualkurva')
  % Öka gradtalet
  A=[A T.^2]; c=A\p, r=p-A*c;  Fi2=r'*r
  S=[S X.^2];  P=S*c;
  subplot(2,2,3); plot(T,p,'x', X,P), title('Gradtal 2')
  subplot(2,2,4); plot(T,r), title('Residualkurva')

