How to include Simulink directories within a compiled app using App Designer?

1 view (last 30 days)
I am working on compiling an app that runs a simulink model on a target computer. The app runs fine from within app designer. However, we would like to compile the app into a standalone application that can be run by simply clicking an icon on the desktop.
I have been running across the error shown in the below picture and am unsure how to solve the problem.
I tried using the "addpath" command. However, modifying the search path is apparently not supported by Matlab Compiler.
I also tried adding the relevant folders shown in the error message to the application by including them in the "Files required for your application to run". The "toolbox/simulink/simulink" folder could not be read for some reason and the inclusion of the "toolbox/simulink/blocks" had no affect on the resulting error message.
Finally I tried including dir("C:\...\toolbox\simulink\...") within the app code's set up function (line 639 of the app's code executes the set up function and the set up function attempts to access the simulink model). This also had no effect.
Any suggestions? Thank you for your time

Answers (1)

Pratyush
Pratyush on 18 Dec 2023
Hi Liam,
I understand that you encounter an error relating to MATLAB path configuration when trying to compile your Simulink model into a standalone application. You could try the following steps to resolve the error:
  • Modifying the search path using 'addpath' is not supported after compilation, and since including the directories in the "Files required for your application to run" did not resolve the issue, you can try to convert your Simulink model to a standalone executable using Simulink Coder before compiling the app. This process generates C/C++ code from the Simulink model that can be executed independently of MATLAB.
  • Instead of using 'addpath' dynamically in your code, set up the required paths statically before compiling the application by using the 'pathtool' command, and then saving the path using 'savepath'.
  • Use the 'deploytool' to package the Simulink model with the application.
  • When using the MATLAB Compiler (mcc), explicitly add the required directories and files using the -a flag to include them in the standalone application.
Hope this helps.

Categories

Find more on Search Path in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!