Software-in-the-Loop Execution with the MATLAB Coder App - MATLAB & Simulink (original) (raw)
Use software-in-the-loop (SIL) execution to verify the numerical behavior of the generated C/C++ code with reference to your original MATLAB® functions.
- To open the MATLAB Coder™ app, on the MATLAB Toolstrip Apps tab, under Code Generation, click the app icon.
- To open your project, click
, and then click
Open existing project
. Select the project. For example,kalman_filter01.prj
. - On the Generate Code page, click theGenerate arrow
.
- In the Generate dialog box:
- Set Build type to
Static Library
orDynamic Library
. - In the Output file name field, use the default value. For example,
kalman01
. - Specify Language.
- Clear the Generate code only check box.
- In the Hardware Board field, use the default value (
MATLAB Host Computer
).
You do not have to specify the Toolchain setting. By default, the MATLAB Coder app locates an installed toolchain.
- Set Build type to
- To generate the C or C++ code, click Generate.
- Click Verify Code.
- In the command field, specify the test file that calls the original MATLAB functions, for example,
test01_ui.m
. - If required, select the Enable source-level debugging for SIL or PIL check box.
- To start the SIL execution, click Run Generated Code.
The MATLAB Coder app:- Generates a standalone library, for example,
codegen\lib\kalman01
. - Generates SIL interface code, for example,
codegen\lib\kalman01\sil
. - Runs the test file, replacing calls to the MATLAB function with calls to the generated code in the library.
- Displays messages from the SIL execution in the Test Output tab.
- Generates a standalone library, for example,
- Verify that the results from the SIL execution match the results from the original MATLAB functions.
- To terminate the SIL execution process, click Stop SIL Verification. Alternatively, on the Test Output tab, click the link that follows
To terminate execution
.
Note
On a Windows® operating system, the Windows Firewall can potentially block a SIL or PIL execution. To allow the execution, use the Windows Security Alert dialog box. For example, in Windows 7, click Allow access.
Related Examples
- Generate C Code by Using the MATLAB Coder App
- Software-in-the-Loop Execution from Command Line
- Debug Generated Code During SIL or PIL Execution
- Generate Execution Time Profile
- Generate Stack Usage Profile