Main Content

Software-in-the-Loop Execution with theMATLABCoder应用程序

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 theMATLAB Coder™app, on the MATLAB Toolstrip应用程序stab, underCode Generation, click the app icon.

  2. To open your project, click, and then clickOpen existing project. Select the project. For example,kalman_filter01.prj.

  3. On theGenerate Codepage, click theGeneratearrow.

  4. In theGeneratedialog box:

    1. SetBuild typetoStatic LibraryorDynamic Library.

    2. In theOutput file namefield, use the default value. For example,kalman01.

    3. SpecifyLanguage.

    4. Clear theGenerate code onlycheck box.

    5. In theHardware Boardfield, use the default value (MATLAB Host Computer).

    You do not have to specify theToolchainsetting. By default, theMATLAB Coderapp locates an installed toolchain.

  5. To generate the C or C++ code, clickGenerate.

  6. ClickVerify Code.

  7. 在命令字段中,指定测试文件that calls the original MATLAB functions, for example,test01_ui.m.

  8. If required, select theEnable source-level debugging for SILcheck box.

  9. To start the SIL execution, clickRun Generated Code.

    TheMATLAB Coderapp:

    • 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 theTest Outputtab.

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

  11. To terminate the SIL execution process, clickStop SIL Verification. Alternatively, on theTest Outputtab, click the link that followsTo 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, inWindows 7, clickAllow access.

Related Examples

More About