


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.7 2008/08/08 12:29:17 hewitson Exp $
NOTE: Taken from code by: 1998.05.25 Masaki Ando
HISTORY: 12-02-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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.7 2008/08/08 12:29:17 hewitson 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.y.']; 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 bs(j) = []; 0080 end 0081 end 0082 0083 % Set output 0084 if nargout > 0 0085 varargout{1} = bs; 0086 end 0087 end 0088 0089 %-------------------------------------------------------------------------- 0090 % Get Info Object 0091 %-------------------------------------------------------------------------- 0092 function ii = getInfo(varargin) 0093 if nargin == 1 && strcmpi(varargin{1}, 'None') 0094 sets = {}; 0095 pl = []; 0096 else 0097 sets = {'Default'}; 0098 pl = getDefaultPlist; 0099 end 0100 % Build info object 0101 ii = minfo(mfilename, 'ao', '', 'Signal Processing', '$Id: rms.m,v 1.7 2008/08/08 12:29:17 hewitson Exp $', sets, pl); 0102 end 0103 0104 %-------------------------------------------------------------------------- 0105 % Get Default Plist 0106 %-------------------------------------------------------------------------- 0107 function pl_default = getDefaultPlist() 0108 pl_default = plist(); 0109 end 0110 % END 0111