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

  1. function x = gengauss(w,p,c)
  2. %GENGAUSS  Generate a gaussian peak of unit height.
  3. %
  4. %      x = gengauss(w)  or   x = gengauss(w,p,c)
  5. %
  6. % where:
  7. %
  8. % w    is the distance from center to 2% of full height
  9. % p    (optional) is the number of points x will contain
  10. % c    (optional) is the point number for the peak center
  11. %
  12. % The peak will be centered in the vector unless p and c are specified.
  13. %
  14.  
  15. % Copyright (c) 1989-92 by The MathWorks, Inc.
  16.  
  17. if nargin == 2, c = 0; end
  18. if nargin == 1, c = 0; p = 0; end
  19.  
  20. if p < 1, points = round(3 * w);
  21.    else points = round(p);
  22. end
  23.  
  24. if c < 1, center = round(points/2);
  25.    else center = round(c);
  26. end
  27.  
  28. w = w/2;
  29. if c < 0, center = center - c; end
  30.  
  31. for n = 1:points,
  32.  
  33.     x(n) = exp(-((n-center)/w)^2);
  34. end
  35.  
  36. x = x';
  37.