view m-toolbox/classes/@pzmodel/respCore.m @ 40:977eb37f31cb database-connection-manager

User friendlier errors from utils.mysql.connect
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 18:04:03 +0100
parents f0afece42f48
children
line wrap: on
line source

% RESPCORE returns the complex response of one pzmodel object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: RESPCORE returns the complex response of one pzmodel object
%              as a data-vector. This function should only be used by the
%              resp method of the ltpda_tf class.
%
% CALL:        r = respCore(obj, f);
%
% VERSION:     $Id: respCore.m,v 1.3 2010/03/15 15:49:53 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function r = respCore(varargin)
  
  %%% Get Inputs
  obj = varargin{1};
  f   = varargin{2}; % Row vector
  
  gain  = obj.gain;
  poles = obj.poles;
  zeros = obj.zeros;
  delay = obj.delay;
  np    = numel(poles);
  nz    = numel(zeros);

  %%% Compute response
  r = gain*ones(size(f));
  
  for j=1:np
    if ~isnan(poles(j).f)
      [f, pr] = resp(poles(j),f);
      r = r .* pr;
    end
  end
  
  for j=1:nz
    if ~isnan(zeros(j).f)
      [f, zr] = resp(zeros(j),f);
      r = r ./zr;
    end
  end
  
  r = r .* exp(-2*pi*f*1i*delay); % Row vector
  
end