Create a function to create a NxN matrix in Python with all elements equal to a given number.
N=5, num=7
def mat_gen(N, num):
    matrix = [[num for col in range(N)] for row in range(N)]
    return matrix

mat_gen(5, 7)