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.10 2008/09/04 15:29:30 ingo 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.10 2008/09/04 15:29:30 ingo 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   [filt, filt_invars, rest] = utils.helper.collect_objects(varargin(:), 'mfir');
0044 
0045   if numel(rest) ~= 1 && ~isnumeric(rest{1})
0046     error('### Please specify the new sample rate.');
0047   end
0048   fs = rest{1};
0049 
0050   %%% Redesing all filters
0051   for kk = 1:numel(filt)
0052     utils.helper.msg(msg.OPROC1, 're-designing filter for fs=%2.2f Hz...', fs);
0053 
0054     fpl  = filt(kk).hist.plistUsed;
0055     type = find(fpl, 'type');
0056     pzm  = find(fpl, 'pzmodel');
0057 
0058     if  strcmpi(type, 'highpass') ||...
0059         strcmpi(type, 'lowpass')  ||...
0060         strcmpi(type, 'bandpass') ||...
0061         strcmpi(type, 'bandreject')
0062 
0063       utils.helper.msg(msg.OPROC2, 're-designing standard filter.');
0064       try
0065         fpl = pset(fpl, 'fs', fs);
0066         utils.helper.msg(msg.OPROC2, 'setting new fs.');
0067       catch
0068         fpl = append(fpl, 'fs', fs);
0069         utils.helper.msg(msg.OPROC2, 'appending parameter fs.');
0070       end
0071       filt(kk) = mfir(fpl);
0072       filt(kk).histout = filt(kk).histout;
0073     elseif ~isempty(pzm)
0074       utils.helper.msg(msg.OPROC2, 're-designing pzmodel filter.');
0075       filt(kk) = mfir(plist([param('pzmodel', pzm) param('fs', fs)]));
0076       filt(kk).histout = filt(kk).histout;
0077     else
0078       warning('!!! un-recognised input filter type. Can''t redesign.');
0079     end
0080   end
0081 
0082   %%% Set output.
0083   varargout{1} = filt;
0084 end
0085 
0086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0087 %                               Local Functions                               %
0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0089 
0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0091 %
0092 % FUNCTION:    getInfo
0093 %
0094 % DESCRIPTION: Get Info Object
0095 %
0096 % HISTORY:     11-07-07 M Hewitson
0097 %                Creation.
0098 %
0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0100 
0101 function ii = getInfo(varargin)
0102   if nargin == 1 && strcmpi(varargin{1}, 'None')
0103     sets = {};
0104     pl   = [];
0105   else
0106     sets = {'Default'};
0107     pl   = getDefaultPlist;
0108   end
0109   % Build info object
0110   ii = minfo(mfilename, 'mfir', '', utils.const.categories.helper, '$Id: redesign.m,v 1.10 2008/09/04 15:29:30 ingo Exp $', sets, pl);
0111 end
0112 
0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0114 %
0115 % FUNCTION:    getDefaultPlist
0116 %
0117 % DESCRIPTION: Get Default Plist
0118 %
0119 % HISTORY:     11-07-07 M Hewitson
0120 %                Creation.
0121 %
0122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0123 
0124 function plo = getDefaultPlist()
0125   plo = plist();
0126 end
0127

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003