


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 (miir) filter
fs - new sample rate
OUTPUT: filt - new output filter
M-FILE INFO: Get information about this methods by calling
>> miir.getInfo('redesign')
Get information about a specified set-plist by calling:
>> miir.getInfo('redesign', 'set')
VERSION: $Id: redesign.m,v 1.14 2008/08/08 14:52:24 hewitson Exp $
HISTORY: 04-04-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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 (miir) 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 % >> miir.getInfo('redesign') 0016 % 0017 % Get information about a specified set-plist by calling: 0018 % >> miir.getInfo('redesign', 'set') 0019 % 0020 % VERSION: $Id: redesign.m,v 1.14 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(:), 'miir'); 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 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) = miir(fpl); 0072 filt(kk).setHistin(filt(kk).histin); 0073 filt(kk).setHistout(filt(kk).histout); 0074 elseif ~isempty(pzm) 0075 0076 utils.helper.msg(msg.OPROC2, 're-designing pzmodel filter.'); 0077 filt(kk) = miir(plist('pzmodel', pzm, 'fs', fs)); 0078 filt(kk).setHistin(filt(kk).histin); 0079 filt(kk).setHistout(filt(kk).histout); 0080 else 0081 warning('!!! un-recognised input filter type. Can''t redesign.'); 0082 end 0083 end 0084 0085 %%% Set output. 0086 varargout{1} = filt; 0087 0088 end 0089 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 % Local Functions % 0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0093 0094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0095 % 0096 % FUNCTION: getInfo 0097 % 0098 % DESCRIPTION: Get Info Object 0099 % 0100 % HISTORY: 11-07-07 M Hewitson 0101 % Creation. 0102 % 0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0104 0105 function ii = getInfo(varargin) 0106 if nargin == 1 && strcmpi(varargin{1}, 'None') 0107 sets = {}; 0108 pl = []; 0109 else 0110 sets = {'Default'}; 0111 pl = getDefaultPlist; 0112 end 0113 % Build info object 0114 ii = minfo(mfilename, 'miir', '', 'Helper', '$Id: redesign.m,v 1.14 2008/08/08 14:52:24 hewitson Exp $', sets, pl); 0115 end 0116 0117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0118 % 0119 % FUNCTION: getDefaultPlist 0120 % 0121 % DESCRIPTION: Get Default Plist 0122 % 0123 % HISTORY: 11-07-07 M Hewitson 0124 % Creation. 0125 % 0126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0127 0128 function plo = getDefaultPlist() 0129 plo = plist(); 0130 end 0131