view m-toolbox/classes/@ao/conv_noisegen.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 source

% CONV_NOISEGEN calls the matlab function conv.m to convolute poles and zeros from a given pzmodel
%
% The function is a private one and is called from ngconv.m in the
% noisegenerator folder.
%
% Inputs (from ngconv.m):
%        - pol
%        - zero
%
% Outputs:
%        - b: denominator coefficients of transfer function
%        - a: numerator coefficients of transfer function
% A Monsky 24-07-07
%
% $Id: conv_noisegen.m,v 1.2 2008/08/01 13:19:42 ingo Exp $
%

function [b,a] = conv_noisegen(pol,zer)

  [m,k] = size(pol);
  [n,l] = size(zer);

  coefb = pol(1,:);

  for i = 2:m
    coefb = conv(coefb, pol(i,:));
  end

  b = nonzeros(coefb);

  if n~=0
    coefa = zer(1,:);
    for i = 2:n
      coefa = conv(coefa, zer(i,:));
    end
    a = nonzeros(coefa);
  else
    a = 1;
  end

  %normalize to bn = 1
  m = length(b);
  normfac = b(m);
  b = b/normfac;
  a = a/(normfac*sqrt(2));

end