DIR='/home/huangx/RNA_GCAA_8mer/assignments/';
numMicro = 10000;
stepSize = 1;

% a sparse matrix of zero.
T = speye(numMicro,numMicro)-speye(numMicro,numMicro);

tic
disp(sprintf('Waiting for computing Transition Count Matrix at step %d...',stepSize));

fnames = dir(DIR);

for i=3:length(fnames),
	traj = load(strcat(DIR,fnames(i).name),'-ascii');
	traj = traj +1; % Convert the range [0, k-1] to [1,k]
	for j=1:length(traj)-stepSize,
			startM = traj(j);  
			endM = traj(j+stepSize);
			T(startM, endM) = T(startM,endM)+1;
	end
end

save(sprintf('T%d_s%d.mat',numMicro,stepSize),'-mat');
toc