Search code examples
matlabmatlab-app-designer

Using Application Compiler for app including rtwbuild()


I would like to use the Application Compiler (Appdesigner -->Standalone Desktop App) on my MATLAB app. This app calls a .m file which is using the rtwbuild command to deploy a Simulink model to an arduino. The app works well when run in MATLAB, however after compilation I receive an error with rtwbuild:

Error using rtwbuild
The Matlab Path must have these directories for Simulink to function:
toolbox/simulink/blocks, toolbox/simulink/simulink
Matlab cannot continue. Please restore the path and restart Matlab

The documentation says, that no Simulink functions are supported for the MATLAB Compiler (see here) and the rtwbuild function seems to be a Simulink function, since it is in the documentation in the category "Simulink Coder" (see here). However, I do not have the Simulink Coder Toolbox and the app was running in MATLAB anyway, so I am not sure if rtwbuild is really a Simulink function. To keep it short, my question is the following: "Is it possible to use the Application Compiler on .m scripts including the rtwbuild command?"

Thank you for your help!


Solution

  • rtwbuild is without a doubt a Simulink Function, which means the MATLAB-Coder can not generate code. More generally speaking, you can not deploy the code generator. Generating code from M or Simulink requires a full MATLAB (Simulink) to be running. It would be foolish to let you use such a key feature without a MATLAB (Simulink) license (personal opinion).

    About your confusion about rtwbild being part of the Simulink Coder. The Support Package for Arduino Hardware allows you to use certain deployment features. You can for example get binaries, you can not access the C code without having a Coder License. For details refer to "Additional Capabilities with Simulink Coder and Embedded Coder" in the documentation.

    The documentation does not reflect these special cases, but obviously TMW did not re-invent the wheel when providing the Support-Packages for Arduino. Instead some "Simulink Coder" functions do not require a Simulink Coder License when used with the code generation Target Arduino. Same is true for the Raspberry and to a limited extend for the (rapid) accelerator mode.