The function works and gives correct output.

The problem with dimension of matrix is solved in general form so it can read in files with different time step.