Deploy MATLAB Application to Control Real-Time Application

Required Products: Simulink®, Simulink Real-Time™, MATLAB® Compiler™, and MATLAB Compiler SDK™

This example shows how to deploy a test script as a standalone executable by using MATLAB Compiler. The test script performs a frequency-response test of the xpcosc model. Using this information, in the design phase, you can modify the internal parameters of the model to meet your frequency requirements. In the production phase, you can bin manufactured parts based on frequency response.

The test script is slrt_freq_sweep_test.m (open(fullfile(matlabroot, 'help','toolbox','xpc','examples','slrt_freq_sweep_test.m'))).

Prerequisites

This procedure assumes that you have:

  1. Completed the steps in MATLAB Runtime Setup.

  2. Opened MATLAB from the Windows® command prompt window within which you performed MATLAB run-time setup.

  3. Configured TCP/IP communication between the development and target computers, recorded the required settings in the test script slrt_freq_sweep_test.m, and saved the script in a working folder.

  4. Built the xpcosc real-time application.

Package the MATLAB Application

  1. Open Apps > Application Compiler.

  2. Enter the name of the application as slrt_freq_sweep_test. Add summary information as required.

  3. To save the project, click Save. Save the project under a name such as slrt_freq_sweep_test.prj.

  4. Click the Add main file button  , and then navigate to the file slrt_freq_sweep_test.m.

  5. Under PACKAGING OPTIONS, select the Runtime included in package check box.

  6. Click the Package button .

    The compiler generates the application and opens the slrt_freq_sweep_test folder in Windows Explorer.

  7. To save the project, click Save.

Run the MATLAB Application

  1. In Windows Explorer, navigate to slrt_freq_sweep_test\for_redistribution_files_only.

  2. Copy the real-time application file (xpcosc.mldatx) into slrt_freq_sweep_test\for_redistribution_files_only.

    The application assumes that the model file is in the folder where you run the application.

  3. If you are connected to the target computer within MATLAB, close the connection. Use the close(tg) command.

  4. To run the application, click slrt_freq_sweep_test.exe.

    The application runs and displays a plot for each frequency.

    After the run is complete, the application displays a text box containing the test results.

Related Topics