0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % FQ2RI Convert frequency/Q pole/zero representation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: FQ2RI Convert frequency/Q pole/zero representation into:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % -Q=Nan: real pole/zero [output: ri]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % -Q>0.5 real and imaginary conjugate pairs [ri conj(ri)]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % -Q=0.5 two equal real poles [ri ri]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % -Q<0.5 two real poles [ri ri]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % CALL: ri= fq2ri(f0, Q)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % VERSION: $Id: fq2ri.m,v 1.10 2011/02/18 16:48:54 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 function ri= fq2ri(f0, Q)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 if(nargin==0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 disp('usage: ri = fq2ri2(f0, Q)')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 elseif(nargin==1 || nargin==2 && isnan(Q))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 ri = -((2*pi*f0));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 elseif(nargin==2 && Q>=0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 if Q < 0.5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 disp('!!! Q < 0.5! Splitting to two real poles/zeros;')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 a = 2*pi*f0/(2*Q)*(1+sqrt(1-4*Q^2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 b = 2*pi*f0/(2*Q)*(1-sqrt(1-4*Q^2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 ri = [a b];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 elseif Q == 0.5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 disp('!!! Q = 0.5! Returning two equal real poles/zeros;')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 w0 = 2*pi*f0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 re = w0/(2*Q);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 ri = [re re];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 w0 = 2*pi*f0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 re = -w0/(2*Q);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 im = w0*sqrt(1-1/(4*Q^2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 tri = complex(re,im);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 ri = [tri; conj(tri)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43
|