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

  1. function [at,bt,ct,dt] = lp2bs(a,b,c,d,wo,bw)
  2. %LP2BS    Lowpass to bandstop analog filter transformation.
  3. %    [NUMT,DENT] = LP2BS(NUM,DEN,Wo,Bw) transforms the lowpass filter
  4. %    prototype NUM(s)/DEN(s) with unity cutoff frequency to a
  5. %    bandstop filter with center frequency Wo and bandwidth Bw.
  6. %    [AT,BT,CT,DT] = LP2BS(A,B,C,D,Wo,Bw) does the same when the
  7. %    filter is described in state-space form.
  8.  
  9. %    J.N. Little & G.F. Franklin  8-4-87
  10. %    Copyright (c) 1987 by the MathWorks, Inc.
  11.  
  12. if nargin == 4        % Transfer function case
  13.     % Transform to state-space
  14.     wo = c;
  15.     bw = d;
  16.     [a,b,c,d] = tf2ss(a,b);
  17. end
  18.  
  19. error(abcdchk(a,b,c,d));
  20. [ma,nb] = size(b);
  21. [mc,ma] = size(c);
  22.  
  23. % Transform lowpass to bandstop
  24. q = wo/bw;
  25. at =  [wo/q*inv(a) wo*eye(ma); -wo*eye(ma) zeros(ma)];
  26. bt = -[wo/q*(a\b); zeros(ma,nb)];
  27. ct = [c/a zeros(mc,ma)];
  28. dt = d - c/a*b;
  29.  
  30. if nargin == 4        % Transfer function case
  31.     % Transform back to transfer function
  32.     b = poly(at);
  33.     at = poly(at-bt*ct)+(dt-1)*b;
  34.     bt = b;
  35. end
  36.