build matrix and debug data output