hacked version of xmatrix that outputs to files