Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@math/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/+utils/@math/fq2ri.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,38 @@ +% FQ2RI Convert frequency/Q pole/zero representation into real +% and imaginary conjugate pairs. +% +% [G,ri]= fq2ri(f0, Q) +% +% M Hewitson 26-01-07 +% +% $Id: fq2ri.m,v 1.3 2008/10/24 09:40:19 hewitson Exp $ +% +function [G,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;') + 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 one real pole;') + w0 = 2*pi*f0; + re = w0/(2*Q); + ri = [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 + +end +% END