Working with callbacks
There are four different callback functions:
- Pre code generation callback function: Callback before the model is converted to C++ code. (
Project.PreCodeGenerationCallbackFcn) - Post code generation callback function: Callback after the model has been converted to C++ code. (
Project.PostCodeGenerationCallbackFcn) - Post publish callback function: Callback after the created C++ project has been built for the configured platforms. (
Project.PostPublishCallbackFcn) - Post deploy callback function: Callback will be executed after the project specified in “Deployment Project” is updated. (
Project.PostDeployCallbackFcn)
Assign the names of the MATLAB® functions you have created to the corresponding properties in the export configuration to call them.
By default, the ProjectExporter object is passed to the function, so that you have access to all data of the current project in the callback function.
For example, an m-file MyCallback.m can be created in the workspace with the following content:
function MyCallback(obj)
…
returnThe Callback function can then be passed to Target for MATLAB® as follows:
exportCfg.Project.PreCodeGenerationCallbackFcn = 'MyCallback';
exportCfg.Project.PostCodeGenerationCallbackFcn = 'MyCallback';
exportCfg.Project.PostPublishCallbackFcn = 'MyCallback';
exportCfg.Project.PostDeployCallbackFcn = 'MyCallback';![]() | Available example in MATLAB® Run the following command in the MATLAB® command line to open the example: |
