MATLAB Answers


Why do I get the error '??? Output argument ‹variable› (and maybe others) not assigned during call to ‹function›.' ?

Why do I get the following error message :

 ??? Output argument ‹variable› (and maybe others) not assigned during call to ‹function›.


No tags are associated with this question.


1 Answer

Answer by MathWorks Support Team on 27 Feb 2012
 Accepted Answer


One of the functions you have called is defined to return an output argument but that output argument does not exist in the function when it tries to return.

Common causes:

You have misspelled the name of one of your output arguments inside your function, or you have forgotten to assign a value to one of the output arguments of your function. Alternatively, the function was originally written with one or more output arguments, but the section of the function that computed the output argument was removed or modified in such a way that the output argument is now extraneous.


Stop MATLAB on the last line of the function listed in the warning or error message. Verify that each of the output arguments listed in the function declaration line at the beginning of the function exist after that last line is executed (using the DBSTEP function or the Step button in the Editor). If the arguments do not exist, examine the function to determine where you intended the arguments to be declared. Verify that those lines of code are being executed and have no typographical errors.

Example demonstrating this error:



I had the similar problem. The problem was I used the clear all at some point in the function so the output variable was cleared.

I had a similar problem, but your example helped clear it up, thanks!

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!