view m-toolbox/classes/@pzmodel/fromPolesAndZeros.m @ 29:54f14716c721 database-connection-manager

Update Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromPolesAndZeros
%
% DESCRIPTION: Construct a pzmodel from poles and zeros
%
% CALL:        pzm = fromPolesAndZeros(a, pl)
%
% PARAMETER:   pl   - plist
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function pzm = fromPolesAndZeros(pzm, pli)

  VERSION = '$Id: fromPolesAndZeros.m,v 1.20 2011/08/15 10:10:33 hewitson Exp $';


  % get pzmodel info
  ii = pzmodel.getInfo('pzmodel', 'From Poles/Zeros');

  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);

  % Combine input plist with default values
  pl = applyDefaults(ii.plists, pli);

  % Set fields
  pzm.gain = find(pl, 'gain');
  ps       = find(pl, 'poles');
  zs       = find(pl, 'zeros');

  % If the poles/zeros in the plist are no pz-objects then convert them
  if ~isa(ps, 'pz') && ~isempty(ps)
    ps = pz(ps);
  end
  if ~isa(zs, 'pz') && ~isempty(zs)
    zs = pz(zs);
  end

  % Add only valid poles
  poles = [];
  for kk = 1:numel(ps)
    if ~isnan(ps(kk).f)
      poles = [poles ps(kk)];
    end
  end
  pl.pset('poles', poles);

  % Add only valid zeros
  zeros = [];
  for kk = 1:numel(zs)
    if ~isnan(zs(kk).f)
      zeros = [zeros zs(kk)];
    end
  end
  pl.pset('zeros', zeros);  
  
  % Set object properties from input plist
  pzm.setObjectProperties(pl);

  % Add history
  pzm.addHistory(ii, pl, [], []);

end