The MATLAB Function documentation page include links to various examples and useful articles that explains the limitations and best practices for writing MATLAB code for code generation:
The Stateflow Application Program Interface (API) is a tool of convenience that allows you to create or edit Stateflow diagrams with MATLAB commands. Refer to the following documentation page to help you get started with using the Stateflow API.
Best Answer