Home > classes > @mfir > redesign.m

redesign

PURPOSE ^

REDESIGN redesign the input filter to work for the given sample rate.

SYNOPSIS ^

function varargout = redesign(varargin)

DESCRIPTION ^

 REDESIGN redesign the input filter to work for the given sample rate.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: REDESIGN redesign the input filter to work for the given sample
              rate.

 CALL:        filt = redesign(filt, fs)

 INPUT:       filt - input (mfir) filter
              fs   - new sample rate

 OUTPUT:      filt - new output filter

 M-FILE INFO: Get information about this methods by calling
              >> mfir.getInfo('redesign')

              Get information about a specified set-plist by calling:
              >> mfir.getInfo('redesign', 'set')

 VERSION:     $Id: redesign.m,v 1.9 2008/08/08 14:52:24 hewitson Exp $

 HISTORY:     04-04-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % REDESIGN redesign the input filter to work for the given sample rate.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: REDESIGN redesign the input filter to work for the given sample
0005 %              rate.
0006 %
0007 % CALL:        filt = redesign(filt, fs)
0008 %
0009 % INPUT:       filt - input (mfir) filter
0010 %              fs   - new sample rate
0011 %
0012 % OUTPUT:      filt - new output filter
0013 %
0014 % M-FILE INFO: Get information about this methods by calling
0015 %              >> mfir.getInfo('redesign')
0016 %
0017 %              Get information about a specified set-plist by calling:
0018 %              >> mfir.getInfo('redesign', 'set')
0019 %
0020 % VERSION:     $Id: redesign.m,v 1.9 2008/08/08 14:52:24 hewitson Exp $
0021 %
0022 % HISTORY:     04-04-2007 M Hewitson
0023 %                 Creation
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 function varargout = redesign(varargin)
0028 
0029   %%% Check if this is a call for parameters
0030   if utils.helper.isinfocall(varargin{:})
0031     varargout{1} = getInfo(varargin{3});
0032     return
0033   end
0034 
0035   import utils.const.*
0036   utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename);
0037   
0038   %%% check numer of outputs
0039   if nargout == 0
0040     error('### cat cannot be used as a modifier. Please give an output variable.');
0041   end
0042 
0043   %%% Get minfo objects
0044   [filt, filt_invars, rest] = utils.helper.collect_objects(varargin(:), 'mfir');
0045 
0046   if numel(rest) ~= 1 && ~isnumeric(rest{1})
0047     error('### Please specify the new sample rate.');
0048   end
0049   fs = rest{1};
0050 
0051   %%% Redesing all filters
0052   for kk = 1:numel(filt)
0053     utils.helper.msg(msg.OPROC1, 're-designing filter for fs=%2.2f Hz...', fs);
0054 
0055     fpl  = filt(kk).hist.plistUsed;
0056     type = find(fpl, 'type');
0057     pzm  = find(fpl, 'pzmodel');
0058 
0059     if  strcmpi(type, 'highpass') ||...
0060         strcmpi(type, 'lowpass')  ||...
0061         strcmpi(type, 'bandpass') ||...
0062         strcmpi(type, 'bandreject')
0063 
0064       utils.helper.msg(msg.OPROC2, 're-designing standard filter.');
0065       try
0066         fpl = pset(fpl, 'fs', fs);
0067         utils.helper.msg(msg.OPROC2, 'setting new fs.');
0068       catch
0069         fpl = append(fpl, 'fs', fs);
0070         utils.helper.msg(msg.OPROC2, 'appending parameter fs.');
0071       end
0072       filt(kk) = mfir(fpl);
0073       filt(kk).histout = filt(kk).histout;
0074     elseif ~isempty(pzm)
0075       utils.helper.msg(msg.OPROC2, 're-designing pzmodel filter.');
0076       filt(kk) = mfir(plist([param('pzmodel', pzm) param('fs', fs)]));
0077       filt(kk).histout = filt(kk).histout;
0078     else
0079       warning('!!! un-recognised input filter type. Can''t redesign.');
0080     end
0081   end
0082 
0083   %%% Set output.
0084   varargout{1} = filt;
0085 end
0086 
0087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0088 %                               Local Functions                               %
0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0090 
0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0092 %
0093 % FUNCTION:    getInfo
0094 %
0095 % DESCRIPTION: Get Info Object
0096 %
0097 % HISTORY:     11-07-07 M Hewitson
0098 %                Creation.
0099 %
0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0101 
0102 function ii = getInfo(varargin)
0103   if nargin == 1 && strcmpi(varargin{1}, 'None')
0104     sets = {};
0105     pl   = [];
0106   else
0107     sets = {'Default'};
0108     pl   = getDefaultPlist;
0109   end
0110   % Build info object
0111   ii = minfo(mfilename, 'mfir', '', 'Helper', '$Id: redesign.m,v 1.9 2008/08/08 14:52:24 hewitson Exp $', sets, pl);
0112 end
0113 
0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0115 %
0116 % FUNCTION:    getDefaultPlist
0117 %
0118 % DESCRIPTION: Get Default Plist
0119 %
0120 % HISTORY:     11-07-07 M Hewitson
0121 %                Creation.
0122 %
0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0124 
0125 function plo = getDefaultPlist()
0126   plo = plist();
0127 end
0128

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003