⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch4_1h.m

📁 清华大学《matlab 控制系统应用与实例》第一部分M文件的源码
💻 M
字号:

% Select a demo number: 9
%       In this demo we consider spectrum estimation, using Marple's
%       test case (The complex data in L. Marple: S.L. Marple, Jr, 
%       Digital Spectral Analysis with Applications, Prentice-Hall,
%       Englewood Cliffs, NJ 1987.)
load marple

%       Most of the routines in the SITB support complex data.
%       For plotting we examine the real and imaginary parts of
%       the data separately, however.
%       First, take a look at the data:
  % Press a key for plot.
subplot(211),plot(real(marple)),title('Real part of data.')
subplot(212),plot(imag(marple)),title('Imaginary part of data.')



%       Let's first check the periodogram of the data;
per = etfe(marple);

figure,ffplot(per)    



%       The spectrum can also be plotted with logarithmic frequency scale
%       as a bodeplot:
figure,bode(per)   


%       Since the data record is only 64 samples, and the periodogram is
%       computed for 128 frequencies, we clearly see the oscilla-
%       tions from the narrow frequency window. We therefore apply some
%       smoothing to the periodogram (corresponding to a frequency resolution
%       of 1/32 Hz):
sp = etfe(marple,32);

figure,ffplot(per,sp)  


%       Let's now try the Blackman-Tukey approach to spectrum estimation:
ssm = spa(marple);

figure,ffplot(sp,'b',ssm,'g')    
        % Blue: Smoothed periodogram.
        % Green: Blackman-Tukey estimate.


%       The default window length gives a very narrow lag window for this
%       small amount of data. We can choose a larger lag window by
ss20 = spa(marple,20);

figure,ffplot(sp,ss20)
        % Blue/solid: Smoothed periodogram.
        % Green/dashed: Blackman-Tukey estimate.

%       A parametric 5-order AR-model is computed by
t5 = ar(marple,5);

%       Compare with the periodogram estimate:
figure,ffplot(sp,'b',t5,'g')   
        % Blue Smoothed periodogram.
        % Green 5th order AR estimate.

%       The AR-command in fact covers 20 different methods for
%       spectrum estimation.  The above one was what is known
%       as 'the modified covariance estimate' in Marple's book.
%       Some other well known ones are obtained with:
tb5 = ar(marple,5,'burg');      % Burg's method
ty5 = ar(marple,5,'yw');        % The Yule-Walker method
 
figure,ffplot(t5,tb5,ty5)
        % blue: Modified covariance
        % green: Burg
        % red: Yule-Walker


%       AR-modeling can also be done using the Instrumental
%       Variable approach:
ti = ivar(marple,4);
 
figure,ffplot(t5,ti)
        % blue: Modified covariance
        % green: Instrumental Variable        

%       Furthermore, the SITB covers ARMA-modeling of spectra:
ta44 = armax(marple,[4 4]);   % 4 AR-parameters and 4 MA-parameters
  
figure,ffplot(t5,ta44)
       % blue: Modified covariance
       % green: ARMA

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -