Why are commands like DISP not displayed in the command window when invoked through ActiveX in MATLAB?

8 views (last 30 days)
The output of commands like DISP are not displayed in the MATLAB command window when invoked through ActiveX in MATLAB.
I am running MATLAB commands using ActiveX. I do not see any of my FPRINTF or DISP commands written in the command window. The following code reproduces the problem:
h =actxserver('Matlab.Application');
invoke(h, 'Execute', 'disp(''hello'')');
No output from DISP is displayed in the automation window.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Debugging commands are not designed to work when MATLAB is started as an automation server. This is because most applications that use the Automation server run without user interaction and would not benefit from having messages displayed to the command window.
The debugging functions that will not work in Automation mode include:
FPRINTF
SSCANF
DISP
A workaround is to use the MSGBOX command to display a status message in a pop-up message box. It is possible to modify the string displayed in a message box instead of creating new message boxes for each status message. For example:
m = msgbox('Original Message')
t= findobj(m,'type','text')
set(t,'String',{'Modified Message'})
Another option is to store the output of a debugging command such as DISP into a string by using the EVALC function. This string can then be pulled into the client application and displayed for debugging purposes.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!