Main Content

Software-in-the-Loop Execution with the MATLAB Coder App

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.

  1. To open the MATLAB Coder™ app, on the MATLAB Toolstrip Apps tab, under Code Generation, click the app icon. The app opens the Create MATLAB Coder Project dialog box.

  2. To open your project, click Open, navigate to the folder that contains your MATLAB Coder project file, and select the file. For example, kalman_filter01.coderprj.

  3. In the Prepare section of the MATLAB Coder tab of the toolstrip:

    1. Specify Language.

    2. Set Output Type to Static Library (.lib) or Dynamic Library (.dll).

  4. In the Generate section of the toolstrip, click Generate Code > Generate Code and Build.

  5. In the Verify section of the toolstrip, use the Run Generated Code > Run file option to specify the test file that calls the original MATLAB functions, for example, test01_ui.m.

  6. Make sure Verification mode is set to Use generated code.

  7. If required, select the Enable source-level debugging for SIL or PIL check box.

  8. 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 Command Window.

  9. Verify that the results from the SIL execution match the results from the original MATLAB functions.

  10. To terminate the SIL execution process, in the Command Window, click the link that follows To terminate execution, for example, clear kalman01_sil.

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.

See Also

Topics