Search code examples
matlabmatlab-compilermcc

Why does Matlab standalone application exit with error "TooManyOutputs"?


I have created a standalone application in Matlab, actually it works, it displays the desired output but it closes immediately, not even enough time to examine the output and read the error message on DOS (standalone mode) that says:

MATLAB:TooManyOutputs 
Warning: 1 visible figure(s) exist at MCR Termination

If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.

Any help would be appreciated.


Solution

  • Looking at the first line of your message, TooManyOutputs suggests that you have an assignment somewhere of the form

    [a b] = somefunction(parameters)
    

    so you want the outputs of somefunction to be put in a and b, but somefunction only returns one parameter. This bug causes your program to terminate, and then MCR realizes the program exits without closing your figure window, causing the later error messages.

    If I'm right about TooManyOutputs, you should already have that error message when running your code directly in Matlab; have you tried that before creating a standalone application?

    If this doesn't help, you should probably post some of your code to make it clearer where the problem could come from.