Home > m > sigproc > frequency_domain > ltpda_rms.m

ltpda_rms

PURPOSE ^

LTPDA_RMS Calculate RMS deviation from spectrum

SYNOPSIS ^

function b=ltpda_rms(a)

DESCRIPTION ^

 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

 VERSION:     $Id: ltpda_rms.html,v 1.1 2007/06/08 14:15:11 hewitson 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:

SOURCE CODE ^

0001 function b=ltpda_rms(a)
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 % VERSION:     $Id: ltpda_rms.html,v 1.1 2007/06/08 14:15:11 hewitson Exp $
0015 %
0016 % NOTE:        Taken from code by: 1998.05.25      Masaki Ando
0017 %
0018 % HISTORY:     12-02-07 M Hewitson
0019 %                Creation
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023 
0024 ALGONAME = mfilename;
0025 VERSION  = '$Id: ltpda_rms.html,v 1.1 2007/06/08 14:15:11 hewitson Exp $';
0026 
0027 % Get input analysis object
0028 if ~isa(a, 'ao')
0029   error('### first input argument should be an analysis object.');
0030 end
0031 
0032 % get data
0033 d   = a.data;
0034 spe = [d.f d.xx];
0035 f   = d.f;
0036 
0037 % start and end frequencies
0038 s = f(1);
0039 e = f(end);
0040 
0041 % compute integrated rms
0042 l1=spe(:,1)>=s;
0043 sp=spe(l1,:);
0044 
0045 l2=sp(:,1)<=e;
0046 sp=sp(l2,:);
0047 
0048 si=size(sp);
0049 li=si(1,1);
0050 
0051 freq=sp(:,1);
0052 sp2=sp(:,2).^2;
0053 ms=sp2;
0054 
0055 for i= li-1 :-1: 1
0056     ms(i)=ms(i+1)+(sp2(i+1)+sp2(i))*(freq(i+1)-freq(i))/2;
0057 end
0058 
0059 % r=[freq,sqrt(ms)];
0060 
0061 % Create output analysis object
0062 % create new output fsdata
0063 fs = fsdata(freq, sqrt(ms), d.fs);
0064 fs = set(fs, 'name', sprintf('RMS(%s)', d.name));
0065 fs = set(fs, 'yunits', d.yunits);
0066 
0067 % create new output history
0068 h = history(ALGONAME, VERSION, [], a.hist);
0069 
0070 % make output analysis object
0071 b = ao(fs, h);
0072 
0073 % set name
0074 b = set(b, 'name', sprintf('RMS(%s)', a.name));
0075 
0076 
0077 
0078

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