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.html,v 1.14 2008/03/31 10:27:39 hewitson 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, varargin) 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.html,v 1.14 2008/03/31 10:27:39 hewitson 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 if ~isempty(varargin) && strcmp(varargin{1}, 'DEBUG') 0040 %%%%%%%%%%%% Do linear frequency for testing 0041 0042 f = [linspace(0, fs/2, Jdes/2 + 1)].'; 0043 L = Jdes * ones(size(f)); 0044 r = fs./L; 0045 m = f./r; 0046 r = []; 0047 rr = []; 0048 rrr = []; 0049 0050 0051 else 0052 %%%%%%%%%%%%% Do log frequency 0053 0054 % Settings 0055 fmin = fs/N; 0056 fmax = fs/2; 0057 j = 1; 0058 f(j) = fmin; 0059 0060 % Initialise constants 0061 rav = fs/N*(1+(1-olap)*(Kdes-1)); 0062 rmin = fs/N*(1+(1-olap)*(Kmin-1)); 0063 g = log(fmax)-log(fmin); 0064 0065 % compute f(j) 0066 while f < fmax 0067 % compute r'(j) 0068 rr(j) = f(j)*g/(Jdes-1); 0069 % compute r''(j) 0070 if rr(j) >= rav 0071 rrr(j) = rr(j); 0072 else 0073 rrr(j) = sqrt(rav*rr(j)); 0074 end 0075 0076 % if this is below the lower possible resolution 0077 if rrr(j) <= rmin 0078 rrr(j) = rmin; 0079 end 0080 0081 % compute L(j) 0082 L(j) = round(fs/rrr(j)); 0083 0084 % compute freq res 0085 r(j) = fs/L(j); 0086 m(j) = f(j)/r(j); 0087 0088 tf = f(j) + r(j); 0089 if tf<fmax 0090 f(j+1) = tf; 0091 j = j + 1; 0092 else 0093 break 0094 end 0095 end 0096 end 0097 0098 0099 %-------------------------------------------------------------------------- 0100 % get default parameter list 0101 function pl = getDefaultPL() 0102 0103 pl = plist(); 0104 pl = append(pl, param('fs', [])); 0105 pl = append(pl, param('N', [])); 0106 pl = append(pl, param('Kdes', [])); 0107 pl = append(pl, param('Kmin', [])); 0108 pl = append(pl, param('Jdes', [])); 0109 pl = append(pl, param('olap', [])); 0110 0111