Simulink.CodeImporter class
Package: Simulink
Description
Use the Simulink.CodeImporter
class to import custom C/C++ code into
Simulink® for modeling, verification, and validation. Instances of this class are used to
specify custom code to import into Simulink.
The Simulink.CodeImporter
class is a handle
class.
Creation
Description
obj = Simulink.CodeImporter()
creates an instance of the
CodeImporter
with the LibraryFileName
property set
to "untitled"
.
obj = Simulink.CodeImporter(
, where
LibName
)LibName
is a file name chosen by the user and specified as a string
or character vector, creates an instance of the CodeImporter
with the
LibraryFileName
property set to LibName
.
Properties
Methods
Examples
Import Custom Code
Specify location and options for custom code.
%% Create code importer object obj = Simulink.CodeImporter('PumpController'); %% Set the custom code to import obj.CustomCode.InterfaceHeaders = ["pumpController.h"]; obj.CustomCode.IncludePaths = ["./include"]; obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"]; %% Specify name for Library Browser obj.Options.LibraryBrowserName = "Controller Library";
Parse custom code and examine results.
%% Parse custom code
s = obj.parse;
obj.ParseInfo
ans = ParseInfo with properties: Success: 1 AvailableFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] EntryFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] AvailableTypes: "pump_control_bus" Errors: []
Import parsed code into Simulink
%% Import code
s = obj.import;
Version History
Introduced in R2021a