view m-toolbox/classes/@miir/fromPzmodel.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

% Construct an miir from a pzmodel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromPzmodel
%
% DESCRIPTION: Construct an miir from a pzmodel
%
% CALL:        f = fromPzmodel(f, pli)
%
% PARAMETER:   type:     String with filter type description
%              pli:       Parameter list object
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function f = fromPzmodel(f, ipzm, pli)
  
  VERSION = '$Id: fromPzmodel.m,v 1.16 2011/08/15 11:22:36 hewitson Exp $';
  ii = miir.getInfo('miir', 'From Pzmodel');
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Add default values
  pl = applyDefaults(ii.plists, pli);
  
  % Get parameters
  if isempty(ipzm)
    pzm = find(pl, 'pzmodel');
  else
    pzm = ipzm;
    pl.remove('pzmodel');
  end
  
  if ~isa(pzm, 'pzmodel')
    error('### The ''From Pzmodel'' constructor requires an input pzmodel');
  end
  
  fs  = find(pl, 'fs');
  
  if isempty(fs)
    % get max freq in pzmodel
    fs = 8*getupperFreq(pzm);
    warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2f Hz.', fs)...
      sprintf('\nThe filter will be redesigned later when used.')]);
  end
  % make MIIR filter
  f = tomiir(pzm, fs);
  
  if isempty(pl.find('name'))
    pl.pset('name', sprintf('iir(%s)', pzm.name));
  end
  if isempty(pl.find('description'))
    pl.pset('description', pzm.description);
  end
  if isempty(pl.find('iunits'))
    pl.pset('iunits', pzm.iunits);
  end
  if isempty(pl.find('ounits'))
    pl.pset('ounits', pzm.ounits);
  end
  
  % Add history
  if isempty(ipzm)
    f.addHistory(ii, pl, [], []);
  else
    f.addHistory(ii, pl, [], ipzm.hist);
  end
  
  % Set object properties
  f.setObjectProperties(pl);
  
end % End fromPzmodel