added function for zipping matrix object