Main Content

Incorrect Number of Output Arguments

By default, the feval and fevalAsync methods request one output argument when calling MATLAB® functions. Some MATLAB functions behave differently depending on the number of output arguments requested. Use the first input argument to specify the number of required output arguments as follows:

  • If you want to call the function with no outputs, specify the first argument as 0

  • If you want to call the function with more than one output, specify the exact number.

For example, the MATLAB disp function does not return an output argument. This call to disp requires one output argument:

engine.feval("disp", 100);
Error using disp
Too many output arguments.

You must specify the number of output arguments explicitly as 0:

engine.feval(0, "disp", 100);

Related Topics