


LTPDA_RMS Calculate RMS deviation from spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: LTPDA_RMS Calculate RMS deviation from spectrum
CALL: b=ltpda_rms(a)
PARAMETERS:
b - analysis object containing RMS deviation
a - input analysis object containing spectrum
The following call returns a parameter list object that contains the
default parameter values:
>> pl = ltpda_rms('Params')
VERSION: $Id: ltpda_rms.m,v 1.5 2007/06/12 12:32:14 hewitson Exp $
NOTE: Taken from code by: 1998.05.25 Masaki Ando
HISTORY: 12-02-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function varargout = ltpda_rms(varargin) 0002 % LTPDA_RMS Calculate RMS deviation from spectrum 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: LTPDA_RMS Calculate RMS deviation from spectrum 0007 % 0008 % CALL: b=ltpda_rms(a) 0009 % 0010 % PARAMETERS: 0011 % b - analysis object containing RMS deviation 0012 % a - input analysis object containing spectrum 0013 % 0014 % The following call returns a parameter list object that contains the 0015 % default parameter values: 0016 % 0017 % >> pl = ltpda_rms('Params') 0018 % 0019 % VERSION: $Id: ltpda_rms.m,v 1.5 2007/06/12 12:32:14 hewitson Exp $ 0020 % 0021 % NOTE: Taken from code by: 1998.05.25 Masaki Ando 0022 % 0023 % HISTORY: 12-02-07 M Hewitson 0024 % Creation 0025 % 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 0028 % Check if this is a call for parameters 0029 if nargin == 1 0030 in = char(varargin{1}); 0031 if strcmp(in, 'Params') 0032 varargout{1} = getDefaultPL(); 0033 return 0034 end 0035 end 0036 0037 ALGONAME = mfilename; 0038 VERSION = '$Id: ltpda_rms.m,v 1.5 2007/06/12 12:32:14 hewitson Exp $'; 0039 0040 0041 % Get input analysis object 0042 a = varargin{1}; 0043 if ~isa(a, 'ao') 0044 error('### first input argument should be an analysis object.'); 0045 end 0046 0047 % get data 0048 d = a.data; 0049 spe = [d.f d.xx]; 0050 f = d.f; 0051 0052 % start and end frequencies 0053 s = f(1); 0054 e = f(end); 0055 0056 % compute integrated rms 0057 l1=spe(:,1)>=s; 0058 sp=spe(l1,:); 0059 0060 l2=sp(:,1)<=e; 0061 sp=sp(l2,:); 0062 0063 si=size(sp); 0064 li=si(1,1); 0065 0066 freq=sp(:,1); 0067 sp2=sp(:,2).^2; 0068 ms=sp2; 0069 0070 for i= li-1 :-1: 1 0071 ms(i)=ms(i+1)+(sp2(i+1)+sp2(i))*(freq(i+1)-freq(i))/2; 0072 end 0073 0074 % r=[freq,sqrt(ms)]; 0075 0076 % Create output analysis object 0077 % create new output fsdata 0078 fs = fsdata(freq, sqrt(ms), d.fs); 0079 fs = set(fs, 'name', sprintf('RMS(%s)', d.name)); 0080 fs = set(fs, 'yunits', d.yunits); 0081 0082 % create new output history 0083 h = history(ALGONAME, VERSION, [], a.hist); 0084 0085 % make output analysis object 0086 b = ao(fs, h); 0087 0088 % set name 0089 b = set(b, 'name', sprintf('RMS(%s)', a.name)); 0090 0091 varargout{1} = b; 0092 0093 0094 %-------------------------------------------------------------------------- 0095 % Get default params 0096 function plo = getDefaultPL() 0097 0098 disp('* creating default plist...'); 0099 plo = plist(); 0100 disp('* done.'); 0101