Q：Matlab Too many output arguments from GUI figure declaration

Q：MATLAB的GUI图形输出变量过多的宣言

I have a GUI that I want to catch errors for and handle with a function I have called generateReport. The first GUI file (there are multiple windows each with it's own programmatic GUI file) is CSTMainWindow and the Program is run from the Celest function.

CeleST:

function CeleST
c(@CSTMainWindow); % line 3
end

c.m is just a wrapper for functions so I can try/catch them so I don't have to write code in every subfunction

In trying to resolve this I found that changing the callback to just resizeMainFigure fixes it which makes sense, but then to get the try/catch behavior I want, I would have to but a block everywhere which I was doing before and I'm trying to avoid.

My question is why am I getting too many output arguments if CSTMainWindow has zero output arguments and neither does resizeMainFigure (below for reference)

Check the last argument to figure that you have. It's a function call to c, which returns nothing, but you're passing it as a parameter to the figure call. c has no return value but, in effect, you're asking for it to return a value for you. Based on the figure documentation, you have to provide a function handle, a cell array containing a function handle, or a string that is a valid MATLAB expression for resizefcn. You might try turning your function call into a string instead: