view m-toolbox/classes/@pz/fq2ri.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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