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

  1. function [c, x] = plspred(a, p, q, w, b, n)
  2. % PLSPRED   Predicts concentrations in unknown spectra.
  3. % Copyright (c) 1989-92 by The MathWorks, Inc.
  4. %
  5. %             PLSPRED predicts concentrations in unknown spectra using
  6. %             desired number of factors from the calibration 
  7. %             generated by PLSF.M
  8. %
  9. %  c = plspred(a, p, q, w, b, n)  or  [c, x] = plspred(a, p, q, w, b, n)
  10. %
  11. % Where:
  12. %
  13. %  c    is the matrix of the unknown's concentrations
  14. %  x    is the residual after decomposition of the unknown spectrum or spectra
  15. %  a    is the unknown spectrum (or spectra)
  16. %  p    is the matrix of spectral factors
  17. %  q    is the matrix of concentration factors
  18. %  w    is the matrix of weights
  19. %  b    is the vector containing the inner relationships
  20. %  n    is the number of factors to use
  21. %
  22. x = a';
  23. c = 0;
  24. [maxrank, h] = size(p);
  25. if n > maxrank, n = maxrank, end;
  26. for h=1:n
  27.     t(:,h) = x * w(h,:)';
  28.     x = x - t(:,h) * p(h,:);
  29.     c = c + b(h) * t(:,h) * q(h,:);
  30. end
  31. c = c';
  32.