Debug MATLAB Function Called by C Engine
When creating MATLAB® functions for use in engine applications, it is good practice to run the functions in MATLAB before calling them through the engine library functions.
After you integrate a MATLAB function into an engine application, you can use the
dbstop and other MATLAB debugging commands to debug the function invoked by the engine application. You
might need to add code to the application to pause processing so that you can enter a debug
command, unless you attach the application to an existing MATLAB session.
Debug Engine Application on Windows
Assume that you have an engine application that calls a MATLAB function
myfcn on Windows®. Add the following statement to your engine code before the call to
myfcn. This code waits for user input.
Start the engine application. The application opens a MATLAB desktop and a Windows console application of MATLAB. At the desktop command prompt, type the following command. Make sure that the function is on your MATLAB path.
In the console window, press Enter. MATLAB enters debug mode; type debug commands in the desktop command window.
Debug Engine Application Attached to Existing MATLAB Session
For information about using an existing MATLAB session, see Attach to Existing MATLAB Sessions. To debug function
called by an engine application, first start MATLAB as an Automation server with one of the following commands.
From the system prompt:
From the MATLAB command prompt:
state = enableservice('AutomationServer',true);
At the MATLAB command prompt, type:
Start the engine application. MATLAB enters debug mode; type debug commands in the MATLAB command window.