From: Steven Lord on

"George Coles" <george(a)quantitative.com> wrote in message
news:hj2haa$g$1(a)fred.mathworks.com...
> Praetorian <ashish.sadanandan(a)gmail.com> wrote in message
> <48c9fecc-e565-4f1d-9277-cd03bff66c51(a)l19g2000yqb.googlegroups.com>...
>> On Jan 18, 10:08 am, Praetorian <ashish.sadanan...(a)gmail.com> wrote:
>> > On Jan 18, 9:27 am, "George Coles" <geo...(a)quantitative.com> wrote:

*snip*

> My test mex code looks just like yours. When the user knows the number of
> args out to expect, I agree this works. But what about when the mex code
> populates the plhs array with a number of arguments that is only known by
> the mex function? Essentially what I need is for the mex function to set
> nargout, not the caller.

As others have said, you can't do this. But your MEX-file can check the
number of outputs it was called with (via the nlhs input) and warn or error
if the caller specified a number of outputs other than what you expected, or
customize its behavior based on that information.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ