LTPDA_COMPUTE_F compute the frequency and resolution vectors for use with mlpsd. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: LTPDA_COMPUTE_F compute the frequency and resolution vectors for use with mlpsd. CALL: [f,r,m,L] = ltpda_compute_f(fs, N, Kdes, Kmin, Jdes, olap) INPUTS: fs - sample frequency of data N - length of data vector Kdes - desired number of averages Kmin - minimun number of averages Jdes - desired number of points in spectrum olap - overlap value (0-1) VERSION: $Id: ltpda_compute_f.m,v 1.3 2007/07/16 12:52:21 ingo Exp $ HISTORY: 22-01-2007 M Hewitson Creation The following call returns a parameter list object that contains the default parameter values: >> pl = ltpda_compute_f('Params') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [f,r,m, L,rr,rrr] = ltpda_compute_f(fs, N, Kdes, Kmin, Jdes, olap) 0002 % LTPDA_COMPUTE_F compute the frequency and resolution vectors for use with mlpsd. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: LTPDA_COMPUTE_F compute the frequency and resolution vectors for 0007 % use with mlpsd. 0008 % 0009 % CALL: [f,r,m,L] = ltpda_compute_f(fs, N, Kdes, Kmin, Jdes, olap) 0010 % 0011 % INPUTS: fs - sample frequency of data 0012 % N - length of data vector 0013 % Kdes - desired number of averages 0014 % Kmin - minimun number of averages 0015 % Jdes - desired number of points in spectrum 0016 % olap - overlap value (0-1) 0017 % 0018 % VERSION: $Id: ltpda_compute_f.m,v 1.3 2007/07/16 12:52:21 ingo Exp $ 0019 % 0020 % HISTORY: 22-01-2007 M Hewitson 0021 % Creation 0022 % 0023 % The following call returns a parameter list object that contains the 0024 % default parameter values: 0025 % 0026 % >> pl = ltpda_compute_f('Params') 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 % Check if this is a call for parameters 0031 if nargin == 1 0032 in = char(fs); 0033 if strcmp(in, 'Params') 0034 f = getDefaultPL(); 0035 return 0036 end 0037 end 0038 0039 % Settings 0040 fmin = fs/N; 0041 fmax = fs/2; 0042 j = 1; 0043 f(j) = fmin; 0044 0045 % Initialise constants 0046 rav = fs/N*(1+(1-olap)*(Kdes-1)); 0047 rmin = fs/N*(1+(1-olap)*(Kmin-1)); 0048 g = log(fmax)-log(fmin); 0049 0050 % compute f(j) 0051 while f < fmax 0052 % compute r'(j) 0053 rr(j) = f(j)*g/(Jdes-1); 0054 % compute r''(j) 0055 if rr(j) >= rav 0056 rrr(j) = rr(j); 0057 else 0058 rrr(j) = sqrt(rav*rr(j)); 0059 end 0060 0061 % if this is below the lower possible resolution 0062 if rrr(j) <= rmin 0063 rrr(j) = rmin; 0064 end 0065 0066 % compute L(j) 0067 L(j) = round(fs/rrr(j)); 0068 0069 % compute freq res 0070 r(j) = fs/L(j); 0071 m(j) = f(j)/r(j); 0072 0073 tf = f(j) + r(j); 0074 if tf<fmax 0075 f(j+1) = tf; 0076 j = j + 1; 0077 else 0078 break 0079 end 0080 end 0081 0082 %-------------------------------------------------------------------------- 0083 % get default parameter list 0084 function pl = getDefaultPL() 0085 0086 pl = plist(); 0087 pl = append(pl, param('fs', [])); 0088 pl = append(pl, param('N', [])); 0089 pl = append(pl, param('Kdes', [])); 0090 pl = append(pl, param('Kmin', [])); 0091 pl = append(pl, param('Jdes', [])); 0092 pl = append(pl, param('olap', [])); 0093 0094