http://www.mathworks.com/matlabcentr...nction-for-gen

I didn't read this cause if I was doing it I would just feed it into the neural network every time =D but this is what you want probably.