home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 6.ddi / CHEM.DI$ / PCRFIT.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  877 b   |  29 lines

  1. function fit = pcrfit(a, c, vc, maxrank)
  2. % PCRFIT  Calculate the fit to the standards  with eigenvectors.
  3. %
  4. %  fit = pcrfit(a, c, vc, maxrank)
  5. %
  6. % Where:
  7. %
  8. %  fit      is the matrix containing information on the fit
  9. %  a        is the absorbance matrix
  10. %  c        is the concentration matrix
  11. %  vc       is the matrix containing the eigenvectors (factors)
  12. %  maxrank  is optional limit to the number of factors tested
  13. %
  14. % The first columns of fit contain the std's of the fit for each
  15. % component.  The last column contains the mean for all components.
  16. %
  17.  
  18. % Copyright (c) 1989-92 by The MathWorks, Inc.
  19.  
  20. [i, j] = size(vc);
  21. [k, l] = size(c);
  22. fit(i, (k + 1)) = 0;
  23. if nargin == 4, i = maxrank; end
  24. for n = 1:i;
  25.    proj = vc(:,1:n)' * a;
  26.    error = (c * proj' * inv(proj * proj') * vc(:,1:n)' * a) - c;
  27. fit(n, :) = [std(error') mean(std(error'))];
  28. end
  29.