modified so the actual sim.matrix is an argument, not just the directory and filename; comments added