Home > classes > @ao > rms.m

rms

PURPOSE ^

RMS Calculate RMS deviation from spectrum

SYNOPSIS ^

function varargout = rms(varargin)

DESCRIPTION ^

 RMS Calculate RMS deviation from spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: RMS Calculate RMS deviation from spectrum

 CALL:        b=rms(a)

 INPUTS:      a  - input analysis object containing spectrum

 OUTPUTS:     b  - analysis object containing RMS deviation

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

              Get information about a specified set-plist by calling:
              >> ao.getInfo('rms', 'None')

 VERSION:     $Id: rms.m,v 1.9 2008/09/05 11:05:29 ingo Exp $

 NOTE:        Taken from code by: 1998.05.25      Masaki Ando

 HISTORY:     12-02-07 M Hewitson
                Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % RMS Calculate RMS deviation from spectrum
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: RMS Calculate RMS deviation from spectrum
0005 %
0006 % CALL:        b=rms(a)
0007 %
0008 % INPUTS:      a  - input analysis object containing spectrum
0009 %
0010 % OUTPUTS:     b  - analysis object containing RMS deviation
0011 %
0012 % M-FILE INFO: Get information about this methods by calling
0013 %              >> ao.getInfo('rms')
0014 %
0015 %              Get information about a specified set-plist by calling:
0016 %              >> ao.getInfo('rms', 'None')
0017 %
0018 % VERSION:     $Id: rms.m,v 1.9 2008/09/05 11:05:29 ingo Exp $
0019 %
0020 % NOTE:        Taken from code by: 1998.05.25      Masaki Ando
0021 %
0022 % HISTORY:     12-02-07 M Hewitson
0023 %                Creation
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 function varargout = rms(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.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0037   
0038   % Collect input variable names
0039   in_names = cell(size(varargin));
0040   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0041 
0042   % Collect all AOs and plists
0043   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0044 
0045   % Decide on a deep copy or a modify
0046   bs = copy(as, nargout);
0047 
0048   % Loop over input AOs
0049   for j=1:numel(bs)
0050     % check input data
0051     if isa(bs(j).data, 'fsdata')
0052       % get data
0053       f = bs(j).data.getX;
0054       spe = [f.' bs(j).data.getY.'];
0055       % start and end frequencies
0056       s = f(1);
0057       e = f(end);
0058       % compute integrated rms
0059       l1=spe(:,1)>=s;
0060       sp=spe(l1,:);
0061       l2=sp(:,1)<=e;
0062       sp=sp(l2,:);
0063       si=size(sp);
0064       li=si(1,1);
0065       freq=sp(:,1);
0066       sp2=sp(:,2).^2;
0067       ms=sp2;
0068       for i= li-1 :-1: 1
0069         ms(i)=ms(i+1)+(sp2(i+1)+sp2(i))*(freq(i+1)-freq(i))/2;
0070       end
0071       % set data
0072       bs(j).setXY(freq, sqrt(ms), 'internal');
0073       % set name
0074       bs(j).setName(sprintf('RMS(%s)', ao_invars{j}), 'internal');
0075       % Add history
0076       bs(j).addHistory(getInfo, plist, ao_invars(j), bs(j).hist);
0077     else
0078       warning('!!! Skipping AO %s - it''s not an frequency series.', ao_invars{j});
0079     end
0080   end
0081 
0082   % Set output
0083   if nargout > 0
0084     varargout{1} = bs;
0085   end
0086 end
0087 
0088 %--------------------------------------------------------------------------
0089 % Get Info Object
0090 %--------------------------------------------------------------------------
0091 function ii = getInfo(varargin)
0092   if nargin == 1 && strcmpi(varargin{1}, 'None')
0093     sets = {};
0094     pl   = [];
0095   else
0096     sets = {'Default'};
0097     pl   = getDefaultPlist;
0098   end
0099   % Build info object
0100   ii = minfo(mfilename, 'ao', '', utils.const.categories.sigproc, '$Id: rms.m,v 1.9 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0101 end
0102 
0103 %--------------------------------------------------------------------------
0104 % Get Default Plist
0105 %--------------------------------------------------------------------------
0106 function pl_default = getDefaultPlist()
0107   pl_default = plist();
0108 end
0109 % END
0110

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