File: zpch2.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (37 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [zers,pols,gain]=zpch2(n,A,omegar)
//[zers,pols,gain]=zpch2(n,A,omegar)
//Poles and zeros of a type 2 Chebyshev analog filter
//gain is the gain of the filter
//H(s)=gain*poly(zers,'s')/poly(pols,'s')
//  n      :Filter order
//  A      :Attenuation in stop band (A>1)
//  omegar :Cut-off frequency in Hertz
//  zers   :Resulting filter zeros
//  pols   :Resulting filter poles
//  gain   :Resulting filter gain
//
//!
//Author F.D.
//Revised by C. Bunks Oct. 24, 1996  
// Copyright INRIA
un=ones(1,n);
v=%pi/(2*n)*(1:2:2*n-1);
w=exp(%i*v);
cosine=real(w);
sine=imag(w);
n2=int(n/2);
if n==2*n2 then,
  zers=%i*omegar*un./cosine;
else,
  zers=%i*omegar*un(1:n-1)./[cosine(1:n2),cosine(n2+2:n)];
end,
Gamma=(A+sqrt(A*A-1))**(1/n);
alpha=-((Gamma-1/Gamma)/2)*sine;
beta=((Gamma+1/Gamma)/2)*cosine;
normal=alpha.*alpha+beta.*beta;
pols=omegar*(alpha-%i*beta)./normal;
gain=abs(real(prod(pols)/prod(zers)));