function aicV = aicfun(xV,pmax)
% aicV = aicfun(xV,pmax)
% AICFUN computes the Akaike Information Criterion (AIC) for AR models with
% order 1 to 'pmax'.
% INPUT
% - xV      : the vector of the time series.
% - pmax    : the largest order to compute autocorrelation for.
% OUTPUT
% - aicV    : the vector of size 'pmax x 1' of values of AIC.

aicV = NaN*ones(pmax,1);
for p=1:pmax
    armod = ar(xV,p);
    aicV(p) = aic(armod);
end
