Home > classes > @ao > resample.m

resample

PURPOSE ^

RESAMPLE overloads resample function for AOs.

SYNOPSIS ^

function b = resample(varargin)

DESCRIPTION ^

 RESAMPLE overloads resample function for AOs.
 
 Usage: b = resample(a, pl)
 
 Parameters:
   'fsout' - specify the desired output sample rate
 
 M Hewitson 19-03-07

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function b = resample(varargin)
0002 
0003 % RESAMPLE overloads resample function for AOs.
0004 %
0005 % Usage: b = resample(a, pl)
0006 %
0007 % Parameters:
0008 %   'fsout' - specify the desired output sample rate
0009 %
0010 % M Hewitson 19-03-07
0011 %
0012 
0013 ALGONAME = mfilename;
0014 VERSION  = '$Id: resample.html,v 1.1 2007/06/08 14:15:03 hewitson Exp $';
0015 
0016 % capture input variables
0017 invars = {};
0018 as = [];
0019 pl = [];
0020 for j=1:nargin
0021   a = varargin{j};
0022   if isa(a, 'ao')
0023     d = a.data;
0024     if isa(d, 'tsdata')
0025       as = [as a];
0026       invars = [invars cellstr(inputname(j))];
0027     else
0028       warning('!!! ignoring non-time-series AO.');
0029     end
0030   end
0031   if isa(a, 'plist')
0032     pl = a;
0033   end
0034 end
0035 
0036 if isempty(pl)
0037   error('### Please give a plist with a parameter ''fsout''.');
0038 end
0039 
0040 fsout = find(pl, 'fsout');
0041 if isempty(fsout)
0042   error('### Please give a plist with a parameter ''fsout''.');
0043 end
0044   
0045 na = length(as);
0046 for j=1:na
0047 
0048   a  = as(j);
0049   d  = a.data;
0050   x  = d.x;
0051   fs = d.fs;
0052   
0053   % resample x
0054   y = resample(x, fsout, fs);
0055   
0056   % make new output tsdata
0057   do = tsdata(y, fsout);
0058   
0059   %--------- create output AO
0060 
0061   % make a new history object
0062   h = history(ALGONAME, VERSION, pl, a.hist);
0063   h = set(h, 'invars', invars);
0064 
0065   % get names for output
0066   if isempty(char(invars{1}))
0067     n1 = a.name;
0068   else
0069     n1 = char(invars{1});
0070   end
0071 
0072   % make output analysis object
0073   b = ao(do, h);
0074   b = set(b, 'name', sprintf('resample(%s)', n1));
0075 
0076 end
0077 
0078 
0079 % END

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003