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.6 2007/07/16 12:52:21 ingo 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: b - analysis object containing RMS deviation 0011 % a - input analysis object containing spectrum 0012 % 0013 % The following call returns a parameter list object that contains the 0014 % default parameter values: 0015 % 0016 % >> pl = ltpda_rms('Params') 0017 % 0018 % VERSION: $Id: ltpda_rms.m,v 1.6 2007/07/16 12:52:21 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 % Check if this is a call for parameters 0028 if nargin == 1 0029 in = char(varargin{1}); 0030 if strcmp(in, 'Params') 0031 varargout{1} = getDefaultPL(); 0032 return 0033 end 0034 end 0035 0036 ALGONAME = mfilename; 0037 VERSION = '$Id: ltpda_rms.m,v 1.6 2007/07/16 12:52:21 ingo Exp $'; 0038 0039 0040 % Get input analysis object 0041 a = varargin{1}; 0042 if ~isa(a, 'ao') 0043 error('### first input argument should be an analysis object.'); 0044 end 0045 0046 % get data 0047 d = a.data; 0048 spe = [d.f d.xx]; 0049 f = d.f; 0050 0051 % start and end frequencies 0052 s = f(1); 0053 e = f(end); 0054 0055 % compute integrated rms 0056 l1=spe(:,1)>=s; 0057 sp=spe(l1,:); 0058 0059 l2=sp(:,1)<=e; 0060 sp=sp(l2,:); 0061 0062 si=size(sp); 0063 li=si(1,1); 0064 0065 freq=sp(:,1); 0066 sp2=sp(:,2).^2; 0067 ms=sp2; 0068 0069 for i= li-1 :-1: 1 0070 ms(i)=ms(i+1)+(sp2(i+1)+sp2(i))*(freq(i+1)-freq(i))/2; 0071 end 0072 0073 % r=[freq,sqrt(ms)]; 0074 0075 % Create output analysis object 0076 % create new output fsdata 0077 fs = fsdata(freq, sqrt(ms), d.fs); 0078 fs = set(fs, 'name', sprintf('RMS(%s)', d.name)); 0079 fs = set(fs, 'yunits', d.yunits); 0080 0081 % create new output history 0082 h = history(ALGONAME, VERSION, [], a.hist); 0083 0084 % make output analysis object 0085 b = ao(fs, h); 0086 0087 % set name 0088 b = set(b, 'name', sprintf('RMS(%s)', a.name)); 0089 0090 varargout{1} = b; 0091 0092 0093 %-------------------------------------------------------------------------- 0094 % Get default params 0095 function plo = getDefaultPL() 0096 0097 disp('* creating default plist...'); 0098 plo = plist(); 0099 disp('* done.'); 0100