view m-toolbox/classes/@ao/ngconv.m @ 13:e05504b18072 database-connection-manager

Move more functions to utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% NGCONV is called by the function fromPzmodel
% it takes the pole zero model pzm (user input to ao constructor)
% as input and returns as
%               outputs:
%                      - a: numerator coefficients
%                      - b: denominator coefficients
%                           of the target transfer function
% A Monsky 24-07-07
%
% $Id: ngconv.m,v 1.4 2008/10/20 08:38:29 anneke Exp $

function [a,b] = ngconv(pzm)

  zs = pzm.zeros;
  ps = pzm.poles;

  f_zer = zeros(length(zs));
  q_zer = zeros(length(zs));
  for j=1:length(zs)
    z = zs(j);
    f_zer(j,1) = z.f;
    q_zer(j,1) = z.q;
    %if isnan(q_zer(j))
    %    q_zer(j,1) = 0;
    %end
    %zv(j,1:2) = [f q];
  end

  f_pol = zeros(length(ps));
  q_pol = zeros(length(ps));
  for j=1:length(ps)
    p = ps(j);
    f_pol(j,1) = p.f;
    q_pol(j,1) = p.q;
    %if isnan(q_pol(j))
    %    q_pol(j,1) = 0;
    %end
  end

  %%% calculate factors from f and q
  pol = ao.fq2fac(f_pol,q_pol);
  zer = ao.fq2fac(f_zer,q_zer);

  %%%
  [b,a] = ao.conv_noisegen(pol,zer);
end