Matlab Simulink and Stateflow gotchas while running simulation with code generation with M functions
While in Simulink and Stateflow, if you use Matlab M functions it appears all local function variables need to be defined in the workspace. While running the simulation you can get errors like:
Undefined function or variable ‘m’. The first assignment to a local variable determines its class.
Function ‘rsi’ (#89.382.383), line 17, column 2:
Launch diagnostic report. While in SImulink and Stateflow, if you use Matlab M functions it appears all local function variables need to be defined in the workspace. This is needced for the Coder during the code generation process. I am sure there is a smarter way but I will dig into it in the near future. Hope this helps somewhat so far. Also, when using Stateflow transitions for Matlab M functions, you need to define the M function on the transition as explained here: http://www.mathworks.com/help/stateflow/ug/example-of-a-matlab-function-in-a-stateflow-chart.html I will post a full set of files with C++ code generated file. Want to know when that happens, join my FREE newsletterNOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!