initial function for creating a matrix