fbpx

Matlab Simulink and Stateflow gotchas while running simulation with code generation with custom M functions

(Last Updated On: May 3, 2013)

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:

“m”

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 newsletter 
NOTE 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!
Don't miss out!
Get my TRADE LIKE A BOSS 2 PDF Books

You will received instantly the download links.

Invalid email address
Give it a try. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top