ip_02_04.m
Upload User: loeagle
Upload Date: 2013-03-02
Package Size: 1236k
Code Size: 1k
Development Platform:

Matlab

  1. % MATLAB script for Illustrative Problem 2.4.
  2. echo on
  3. N=1000;
  4. M=50;
  5. Rx_av=zeros(1,M+1);
  6. Sx_av=zeros(1,M+1);
  7. for j=1:10,        % Take the ensemble average over ten realizations
  8.    X=rand(1,N)-1/2;    % N i.i.d. uniformly distributed random variables
  9.                % between -1/2 and 1/2.
  10.    Rx=Rx_est(X,M);          % autocorrelation of the realization
  11.    Sx=fftshift(abs(fft(Rx)));   % power spectrum of the realization
  12.    Rx_av=Rx_av+Rx;          % sum of the autocorrelations
  13.    Sx_av=Sx_av+Sx;          % sum of the spectrums
  14.    echo off ; 
  15. end;
  16. echo on ; 
  17. Rx_av=Rx_av/10;                 % ensemble average autocorrelation
  18. Sx_av=Sx_av/10;             % ensemble average spectrum
  19. % Plotting comments follow