MATLAB Examples

Example 8.2.4 Periodogram of White Noise.

Contents

Workspace Initialization.

clc; clear; close all;

Signal Definition

N = [64 128 256 512];

NumOfRuns = 50;    % Number of periodograms to be calculated for every different data record.
PerLength = 2048;  % This is the fft length used to calculate the periodogram.
freq = 0:2/(PerLength-1):2;
h1 = figure('NumberTitle', 'off','Name', ...
                   'Figure 8.9 The Periodogram of unit Variance White Gaussian Noise',...
                   'Visible','off','Position', [100 0 800 800]);

for m=1:length(N)
    Px = zeros(NumOfRuns,PerLength);
    for k=1:NumOfRuns
          x = randn(1,N(m));
         Px(k,:) = per(x,PerLength);
    end
    subplot(4,2,2*m-1)
    plot(freq(1:PerLength/2),10*log10(Px(:,1:PerLength/2)),'k','LineWidth',0.1)
    title(['Overlay plot of ',num2str(NumOfRuns),' periodograms using ',num2str(N(m)),' data samples'])
    grid on;
    axis tight;
    ylim([-40 20])
    % xlabel('Frequency (units of pi)');

Plot the Periodograms.

    subplot(4,2,2*m)
    plot(freq(1:PerLength/2),1/NumOfRuns*sum(10*log10(Px(:,1:PerLength/2))),'r','LineWidth',1)
    title(['Average of ',num2str(NumOfRuns),' periodograms using ',num2str(N(m)),' data samples'])
    axis tight;
    ylim([-30 10])
    grid on;
end

% Restore the visibility of the figure.
set(h1, 'Visible','on');