matrix preparation