You can integrate custom code written in C or C++ with Stateflow® charts in Simulink® models. By sharing data and functions between your custom code and your Stateflow chart, you can augment the capabilities of Stateflow and leverage the software to take advantage of your preexisting code. For more information, see Reuse Custom Code in Stateflow Charts.
If you specify paths and files with absolute paths and later move them, you must change these paths to point to new locations. To avoid this problem, use relative paths for custom code options that specify paths or files.
Search paths exist relative to these folders:
The current folder
The model folder (if different from the current folder)
The custom list of folders that you specify
All the folders on the MATLAB® search path, excluding the toolbox folders
When you construct relative paths for custom code, follow these syntax rules:
You can use the forward slash (
/) or backward slash
\) as a file separator, regardless of whether you
are on a UNIX® or PC platform. The makefile generator returns the path names
with the correct platform-specific file separators.
You can use tokens that evaluate in the MATLAB workspace, if you enclose them with dollar signs
$...$). For example, consider this
In this example,
mydir1 is a variable that you define
in the MATLAB workspace as
the generated code, this custom include path appears
You must enclose paths in double quotes if they contain spaces or other nonstandard path characters, such as hyphens (-).