How do I include a custom library in the generated code instead of the original library that Stateflow Coder includes?

2 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Follow the steps below to include your custom library instead of the original library:
1. If you want to replace the call to 'math.h' and replace it with your custom library 'mymath.h', open up 'math.h' privided by the compiler and look for an include guard such as that shown below.
The Microsoft provided 'math.h' contains the include guard:
#ifndef _INC_MATH
#define _INC_MATH
......
On UNIX, the include guard is as follows:
#ifndef _MATH_H
#define _MATH_H
.....
2. To customize the code generated by the Stateflow target, go to Tools => RTW Target from the Stateflow chart. Now click on the 'Target Options..' button. This will bring up a window which says "Custom Code included at the top of the generated code" at the top of a pull-down menu.
In this window, insert a #define of this include guard:
#define _INC_MATH
This tells the preprocessor not to include 'math.h' from the compiler.
Refer to the Related Solution for information on how to integrate custom C code into Stateflow.

More Answers (0)

MathWorks Support

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!