function mcm = markovcm(sigmasq, rho, len)
% MARKOVCM Generates a Markov covariance matrix.
%	Takes scalar sigmasq, rho, len, and generates the Markov
%	covariance function r(n)=sigmasq rho^|n| for length len.
%	The covariance matrix is then generated from this.

error(nargchk(3,3,nargin));
if (size(sigmasq,1)~=1) | (size(sigmasq,2)~=1)
  error('sigmasq must be scalar')
end
if (size(rho,1)~=1) | (size(rho,2)~=1)
  error('rho must be scalar')
end
if (size(len,1)~=1) | (size(len,2)~=1)
  error('len must be scalar')
end

mcf = [];
for i=1:len
  mcf(i) = sigmasq * rho^abs(i-1);
end
mcf = mcf';
mcm = toeplitz(mcf,mcf);

