Matlab coder now seems to support dynamic memory allocation (that wasn't the case when I last used it around 2008).
A full example: http://www.mathworks.de/products/matlab-coder/examples.html?file=/products/demos/shipping/coder/coderdemo_atoms.html
Update: For dynamically sized arrays Matlab uses EMX data structures: http://www.mathworks.de/de/help/fixedpoint/ug/c-code-interface-for-unbounded-arrays-and-structure-fields.html