Debug an Application for Deployment
This topic provides high-level tips on debugging the standalone applications. The following lists highlight the solutions and tips for most frequently encountered errors.
Debug Application in Simulink
Use the following tips while preparing the standalone application to be deployed:
To ensure that the model runs successfully in rapid accelerator mode correctly, run the rapid accelerator target in a writable directory.
While writing the script, ensure that the
simcommand uses theSimulink.SimulationInputobject as the input.
If you see the error "Unable to resolve the name
Simulink.SimulationInput", check that the model is on the path.If the dependent files are located in another directory, attach them by using the flag
-a. For example,mcc -m scriptName.m -a myDataFile.dat.
If you are using a function as string, either:
– Add a function pragma
%#function.set(gca, 'ButtonDownFcn', 'foo'); % function foo is a string here.
%#function foo set(gca, 'ButtonDownFcn', 'foo'); % function foo is a string here.
– Write it as an anonymous function
set(gca, 'ButtonDownFcn', @foo);
Simulink.SimulationInput object and Variables
Use the Simulink.SimulationInput object as a way to provide new or
different variable values for the variables that may be stored in base workspace, model
workspace, data dictionary, or projects. Using loadVariablesFromMATFile
with the Simulink.SimulationInput object to provide the variables
directly to the model during simulation can result in an error during deployment with
mcc.
The function mcc only compiles the model and does not simulate the
model. The function mcc performs a dependency analysis on the deployed
script to figure out what to include in the deployed package. When the function
mcc is running, the variables that are specified through a
Simulink.SimulationInput object may not be available.
Debug Application
Callback functions in the model might include functions that are not deployable. Ensure that the functions in the callbacks of the model are deployable.
Callback functions are not invoked at runtime. Ensure that the deployed simulation application does not use callback functions that are required to be invoked at runtime.