diff m-toolbox/classes/@pz/fq2ri.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@pz/fq2ri.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,43 @@
+% FQ2RI Convert frequency/Q pole/zero representation
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: FQ2RI Convert frequency/Q pole/zero representation into: 
+%                  -Q=Nan: real pole/zero  [output: ri]
+%                  -Q>0.5 real and imaginary conjugate pairs [ri conj(ri)]
+%                  -Q=0.5 two equal real poles [ri ri]
+%                  -Q<0.5 two real poles [ri ri]
+% 
+% CALL:        ri= fq2ri(f0, Q)
+%
+% VERSION:     $Id: fq2ri.m,v 1.10 2011/02/18 16:48:54 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function ri= fq2ri(f0, Q)
+
+  if(nargin==0)
+    disp('usage: ri = fq2ri2(f0, Q)')
+    return
+  elseif(nargin==1 || nargin==2 && isnan(Q))
+    ri = -((2*pi*f0));
+  elseif(nargin==2 && Q>=0)
+    if Q < 0.5
+      disp('!!! Q < 0.5! Splitting to two real poles/zeros;')
+      a = 2*pi*f0/(2*Q)*(1+sqrt(1-4*Q^2));
+      b = 2*pi*f0/(2*Q)*(1-sqrt(1-4*Q^2));
+      ri = [a b];
+    elseif Q == 0.5
+      disp('!!! Q = 0.5! Returning two equal real poles/zeros;')
+      w0  = 2*pi*f0;
+      re  = w0/(2*Q);
+      ri  = [re re];
+    else
+      w0  = 2*pi*f0;
+      re  = -w0/(2*Q);
+      im  = w0*sqrt(1-1/(4*Q^2));
+      tri = complex(re,im);
+      ri  = [tri; conj(tri)];
+    end
+
+  end
+