function [Y]=rpsTDembed(x,dim,tau)
% Usage: [Y]=rpsTDembed(x,dim,tau)
% Function to embed the given scalar time series (x) into a higher dimensional space (of dimension dim)
% using delay coordinates with a time delay of tau.
N = length(x);

% Total points on phase space 
num = N - (dim-1)*tau;

% The phase space will be stored in Y
Y=zeros(num,dim);

% Phase space reconstructed from time-delay embedding
for i = 1 : num
   Y(i,:)=x(i+(0:dim-1)*tau)';
end
