MTM:matlab实现2参数解析
生活随笔
收集整理的這篇文章主要介紹了
MTM:matlab实现2参数解析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
之前講了MTM(多錐形窗譜估計)的相關原理,現在來分析一下它的matlab實現。
想要復習的可以參考一下之前的文件:
現代譜估計:多窗口譜
想要復習一下如何實現的可以參考:
MTM:matlab實現1MTM:matlab實現1
目錄
- 前言
- 目錄
- 正文
- parseinputs
- computeDFT
正文
接著上回的講剩下的那兩個子函數:
parseinputs
解析輸入的列表參數 解析輸入傳遞到pmtm.m的參數并返回一個結構包括所有的參數傳遞給pmtm集合,可能是默認值也可能是用戶定義的值。 %---------------------------------------------------------------------- function params = parseinputs(x,varargin) %PARSEINPUTS Parse the inputs passed to pmtm.m and return a structure % containing all the parameters passed to PMTM set to either % default values or user defined values. % 輸入 x 輸入的數據向量 vararginpmtm傳給的輸入參數列表,除了數據x % Inputs: % x - Input data vector. % varargin - Input parameter list passed to pmtm, except for x. %輸出 params 是個結構體,包含了pmtm的輸入參數列表,除了輸入數據x,它 包含以下值域。 % Outputs: % params - Structure containing pmtm's input parameter list, except for % the input data sequence, x; it contains the following fields: nfft 評估psd的頻率點數,默認是接近輸入的2的n次方% nfft - Number of frequency points to evaluate the PSD at; % the default is max(256,2^nextpow2(N)).Fs 采樣頻率 % Fs - The sampling frequency; default is . range 默認是單邊,復信號是雙邊。% range - default is 'onesided' or real signals and 'twosided' for % - complex signals. conflevel 置信度水平% conflevel- Confidence level (preferred syntax)置信度水平,默認是0,95 % ConfInt - Confidence interval; default is .95. (legacy syntax)譜估計時使用的方法,默認的是adaptive。 % MTMethod - Algorithm used in MTM; default is 'adapt'. E 包含有離散扁球序列的矩陣 % E - Matrix containing the discrete prolate spheroidal % sequences. v 向量包含 dpss的中心% V - Vector containing the concentration of the dpss.NW 時間帶寬積 % NW - Time-bandwidth product; default is 4. % err——msd 反饋錯誤信息。 % err_msg - String containing an error message if an error occurred. 錯誤信息提示 if any(strcmp(varargin, 'whole'))warning(message('signal:pmtm:invalidRange', 'whole', 'twosided')); elseif any(strcmp(varargin, 'half'))warning(message('signal:pmtm:invalidRange', 'half', 'onesided')); end 初始化默認的參數值 % Set default parameter values. N = size(x,1); params = [];解析輸入參數到NFFT,如果包含 如果沒有指定e和v,則計算它們 % Parse the input arguments up to NFFT (exclusive). % If E and V are not specified, calculate them. [E,V,NW,indx,nfft_temp,varargin] = getEV(N,varargin{:});強制執行精確規則 % Cast to enforce Precision Rules if (any([signal.internal.sigcheckfloattype(x,'single','pmtm','X') ...signal.internal.sigcheckfloattype(E,'single','pmtm','E') ...signal.internal.sigcheckfloattype(V,'single','pmtm','V')]))x = single(x);E = single(E);V = single(V); end NW 數值轉化 NW = double(NW); 如果x是實數,且nfft的長度《=1 if isreal(x) && (length(nfft_temp) <= 1), range = 'onesided'; elserange = 'twosided'; end注意:功率譜估計函數要求一個包含以下值域的結構體,任何對這個結構的改變,都必須在調用后做完。 % NOTE: The psdoptions function REQUIRES a structure with the following % fields. Any changes to the structure, such as adding/removing % fields, should be done after the call to psdoptions.params.nfft = max(256,2^nextpow2(N)); params.Fs = []; params.range = range; params.centerdc = false; params.conflevel = 'omitted'; 遺漏設置 params.ConfInt = 'omitted'; params.MTMethod= 'adapt'; 調用功率譜選項來解決遺留的以NFFT開始的輸入參數列表 % Call psdoptions to handle the remaining input arg list starting with NFFT. 重寫默認選項,使用用戶特定的值。 % Overwrite default options with user specified options (if specified). 如果indx小于 參數的數量 if indx <= numel(varargin)檢測相關輸入參數是否合法。% Invalid character inputs for NW, NFFT, W, E,V and Fs is checked here[params,err_msg,err_msgobj] = psdoptions(isreal(x),params,varargin{indx:end});if err_msg, error(err_msgobj), end; if ~strcmp(params.conflevel,'omitted') && ~strcmp(params.ConfInt, 'omitted')% user specified too many scalar inputs in conjunction with 'ConfidenceLevel'error(message('signal:pmtm:TooManyScalarNumericInputs'));endif length(params.nfft) > 1,if strcmpi(params.range,'onesided')warning(message('signal:pmtm:InconsistentRangeOption'));endparams.range = 'twosided'`# ##end得到子函數的生成的dpss % Add remaining fields to the return structure. params.E = E; params.V = V; params.NW = NW;computeDFT
computeDFT Computes DFT using FFT or GoertzelThis function is used to calculate the DFT of a signal using the FFT or the Goertzel algorithm. [XX,F] = computeDFT(XIN,NFFT) where NFFT is a scalar and computes the DFT XX using FFT. F is the frequency points at which the XX is computed and is of length NFFT.[XX,F] = computeDFT(XIN,F) where F is a vector with at least two elements computes the DFT XX using the Goertzel algorithm. [XX,F] = computeDFT(...,Fs) returns the frequency vector F (in hz)where Fs is the sampling frequencyInputs:XIN is the input signalNFFT if a scalar corresponds to the number of FFT points used to calculate the DFT using FFT.NFFT if a vector corresponds to the frequency points at which the DFTis calculated using goertzel.FS is the s mp ing frequency總結
以上是生活随笔為你收集整理的MTM:matlab实现2参数解析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 机器人绳索英雄下载苹果手机_警察机器人绳
- 下一篇: c语言 在歌星大奖赛,C语言 歌星大奖