Added create_Z function for Z matrix