Matrix Flatten

A simple function that takes a 3d matrix and convert it to 1D vector.