modify calctransitionmatrix.m