home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 8.ddi / SIGNAL.DI$ / CHEBWIN.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  975 b   |  42 lines

  1. function c = chebwin(nf, ripple)
  2. %CHEBWIN Chebyshev window.
  3. %    CHEBWIN(N,R) returns the N-point Chebyshev window with R decibels
  4. %    of ripple.  N must be odd.  If N is even, an odd N+1 length window
  5. %    is returned.
  6.  
  7. %    L. Shure 3-4-87
  8. %    Revised 4-2-87 JNL
  9. %    Copyright (c) 1987 by the MathWorks, Inc.
  10.  
  11. dp = 10.^(-ripple/20);
  12. odd = rem(nf,2);
  13. if (~odd)
  14.    disp('Chebwin: N must be odd - N is being increased by 1.')
  15.    odd = 1;
  16.    nf = nf+1;
  17. end
  18. n = fix((nf+1)/2);
  19. nm = fix(nf/2+1);
  20. xn = nf-1;
  21. c1 = acosh((1+dp)/dp);
  22. c2 = cosh(c1/xn);
  23. df = acos(1/c2)/pi;
  24. x0 = (3-cos(2*pi*df))/(1.+cos(2*pi*df));
  25. alpha = (1+x0)/2;
  26. beta = (x0-1)/2;
  27. c2 = xn/2;
  28. xi = (0:nf-1);
  29. f = xi/nf;
  30. x = alpha*cos(2*pi*f) + beta;
  31. tmp = (abs(x) > 1);
  32. j = sqrt(-1);
  33. p = dp*(tmp.*(cosh(c2.*acosh(x)))+(1-tmp).*cos(c2.*acos(x)))+j*zeros(1,nf);
  34. if (~odd)
  35.    p = real(p)*exp(-j*pi*f);
  36.    p(nm+1:nf) = -p(nm+1:nf);
  37. end
  38. c = real(fft(p));
  39. c = c(1:n)/c(1);
  40. c = [c(n:-1:odd+1) c]';
  41.  
  42.