MATLAB nargchk deprecated

I updated MATLAB from R2015b to R2016a today. R2016a gives the following warning.

Warning: NARGCHK will be removed in a future release. Use NARGINCHK or NARGOUTCHK instead.

Warning id on MATLAB: ‘MATLAB:nargchk:deprecated’.

Will cvx be updated accordingly? I’m currently using cvx Version 2.1, Build 1103.

1 Like

Thanks for the heads-up! I don’t have a timeline for a fix but thankfully it isn’t fatal (yet).

Any update on this topic?

Also, any way to suppress this particular warning without making changes to cvx itself? Other warnings that may arise from e.g. my own code should still be visible though.

I think you can suppress just that particular warning per . I believe this should work on CVX invocations if you suppress the warning at the MATLAB command line. But you would be suppressing all instances of that warning, in or outside CVX, at least until you unsuppress it.

@Mark_L_Stone, That’s not a solution as soon it will generate an error not only a Warning.

Is CVX still under development?
It seems CVX GitHub Repository haven’t been updated for years.

I opened an issue on this on the repository.

That’s actually not the master repository; I just haven’t pushed there in awhile… There is no doubt that CVX development has slowed considerably. But I believe I pushed a fix for this for 2.1, at least…

@mcg, Do you mean we should download CVX from its main site?
Is there a page with release notes?

I really look forward to CVX 3.0.
CVX is amazing tool, really!

Download CVX at the CVX download page on


Any release notes page?
Something to know which version is downloaded?

Right now, says
Version 2.1, October 2016, Build 1112

If CVX is installed, the command cvx_version displays the CVX, MATLAB, OS , and JAVA versions, as well as license information.

@mcg, The solution isn’t good.

It seems you created a new function called narginchk().
Now the problem a function of MathWorks (Built In MATLAB Function) called makehgtform(varargin) is calling narginchk(ai,inf); on its 44 line.

The function is used for Handlers of the Legend in any Figure of MATLAB and your function creates an error and the Legends becomes wrong.

Actually when CVX is added to MATLAB’s path, this is the result:

Warning: Function narginchk has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. 

The only solution now is to manually (Or in the script) remove CVX from the MATLAB Path.
Needless to say it is a bad user experience.

It seems you must follow MathWorks advise as described here -

Thank You.

P. S.
For the time being, the warning as given in previous builds is much better than this.

How frustrating! Sorry about that. We’ll work on a fix.

Hi Michael,

A fix would be a great “Christmas” present.

Thank you for your kindness.

Royi, can you please try something for me? Can you simply remove the version of narginchk that I added to CVX, and see if that fixes your issue?

The reason I’m asking is this: my replacement narginchk is not supposed to be added to the MATLAB path if the built-in version already exists—in other words, effectively not for any recent version of MATLAB.

Hi Michael,

It seems to work (MATLAB R2016b).

Thank You.

That’s great. Now the mystery to me is why the CVX version is being added to your path in the first place. It shouldn’t be: cvx_setup should see that narginchk is already available and should not add it to the path.

@mcg, It seems to be my bad.
I don’t like having lot of folders in my path.

Hence what I do is I run setup and then remove folders added by CVX from MATLAB’s Path (Restores the original path).
Then, whenever there is a script which uses CVX I add all CVX folder to path.

Now that I understand the problem I just removed that file and everything works!
Sorry for the trouble I caused.

Thank You.

Your approach would work if, instead of adding all of CVX’s folders to your path, you add just the ones that CVX itself adds during the cvx_setup process.


I see you update CVX from time to time.
Any chance for a page with Release Notes?

It would be appreciated to know what has changed form a version to a version.

Thank You.