view m-toolbox/classes/+utils/@math/Rcovmat.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Compute R matrix
% 
% CALL 
% 
% Get R
% R = Rcovmat(x)
% 
% INPUT
% 
% - x data series

% 
%
% L Ferraioli 10-10-2010
%
% $Id: Rcovmat.m,v 1.1 2010/11/16 16:41:37 luigi Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function R = Rcovmat(x)

  % willing to work with rows
  if size(x,1)>size(x,2)
    x = x.';
  end
  % subtract the mean
  x = x - mean(x);
  
  nx = size(x,2);
  
  x = fliplr(x);
    
  % init trim matrix
  R = zeros(nx,nx);
  % fillin the trim matrix
  for ii=1:nx
    R(ii,ii:nx) = x(1:nx-ii+1);
  end
  




end