Home > classes > @miir > redesign.m

redesign

PURPOSE ^

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

SYNOPSIS ^

function filt = redesign(filt, fs)

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 (miir) filter
              fs   - new sample rate

 OUTPUT:      filt - new output filter

 VERSION:     $Id: redesign.html,v 1.14 2008/03/31 10:27:42 hewitson Exp $

 HISTORY:     04-04-2007 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function filt = redesign(filt, fs)
0002 % REDESIGN redesign the input filter to work for the given sample rate.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: REDESIGN redesign the input filter to work for the given sample
0007 %              rate.
0008 %
0009 % CALL:        filt = redesign(filt, fs)
0010 %
0011 % INPUT:       filt - input (miir) filter
0012 %              fs   - new sample rate
0013 %
0014 % OUTPUT:      filt - new output filter
0015 %
0016 % VERSION:     $Id: redesign.html,v 1.14 2008/03/31 10:27:42 hewitson Exp $
0017 %
0018 % HISTORY:     04-04-2007 M Hewitson
0019 %                 Creation
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023 VERSION  = '$Id: redesign.html,v 1.14 2008/03/31 10:27:42 hewitson Exp $';
0024 CATEGORY = 'Helper';
0025 
0026 % Check if this is a call for parameters
0027 if nargin == 2
0028   if isa(filt, 'miir') && ischar(fs)
0029     in = char(fs);
0030     if strcmp(in, 'Params')
0031       filt = plist;
0032       return
0033     elseif strcmp(in, 'Version')
0034       filt = VERSION;
0035       return
0036     elseif strcmp(in, 'Category')
0037       filt = CATEGORY;
0038       return
0039     end
0040   end
0041 end
0042 
0043 disp(sprintf('*** re-designing filter for fs=%2.2f Hz...', fs));
0044 fpl  = get(filt, 'plist');
0045 type = find(fpl, 'type');
0046 pzm  = find(fpl, 'pzmodel');
0047 
0048 if  strcmp(type, 'highpass') ||...
0049     strcmp(type, 'lowpass') ||...
0050     strcmp(type, 'bandpass') ||...
0051     strcmp(type, 'bandreject')
0052 
0053   disp('   - re-designing standard filter.');
0054   try
0055     fpl = pset(fpl, 'fs', fs);
0056     disp('   - setting new fs.');
0057   catch
0058     fpl = append(fpl, 'fs', fs);
0059     disp('   - appending parameter fs.');
0060   end
0061   filtnew = miir(fpl);
0062   filtnew = set(filtnew, 'histin', get(filt, 'histin'));
0063   filtnew = set(filtnew, 'histout', get(filt, 'histout'));
0064   filt = filtnew;
0065 elseif ~isempty(pzm)
0066 
0067   disp('   - re-designing pzmodel filter.');
0068   filtnew = miir(plist([param('pzmodel', pzm) param('fs', fs)]));
0069   filtnew = set(filtnew, 'histin', get(filt, 'histin'));
0070   filtnew = set(filtnew, 'histout', get(filt, 'histout'));
0071   filt = filtnew;
0072 
0073 else
0074 
0075   warning('!!! un-recognised input filter type. Can''t redesign.');
0076 
0077 
0078 
0079 end
0080 
0081 
0082 
0083 
0084 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003