%% Reflection Coefficients for Model Order Determination
% Create a realization of an AR(4) process. Use arburg to determine the reflection coefficients. Use the reflection coefficients to determine an appropriate AR model order for the process. Obtain an estimate of the process PSD.
% Create a realization of an AR(4) process 1000 samples in length. Use arburg with the order set to 12 to return the reflection coefficients. Plot the reflection coefficients to determine an appropriate model order.

A = [1 -2.7607 3.8106 -2.6535 0.9238];

rng default

x = filter(1,A,randn(1000,1));

[a,e,k] = arburg(x,12);

stem(k,'filled')
title('Reflection Coefficients')
xlabel('Model Order')

%
% The reflection coefficients decay to zero after order 4. This indicates an AR(4) model is most appropriate.
% Obtain a PSD estimate of the random process using Burg's method. Use 1000 points in the DFT. Plot the PSD estimate.

pburg(x,4,length(x))

% Copyright 2015 The MathWorks, Inc.