MATLAB nargchk deprecated

(Varun Vasudevan) #1

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.

How to resolve cvx setup error
(Michael C. Grant) #2

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.

(Mark L. Stone) #4

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.

(Royi) #5

@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.

(Michael C. Grant) #6

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…

(Royi) #7

@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!

(Mark L. Stone) #8

Download CVX at the CVX download page on

(Royi) #9


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

(Mark L. Stone) #10

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.

(Royi) #11

@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.

Cvx_setup error
(Michael C. Grant) #12

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

(Royi) #13

Hi Michael,

A fix would be a great “Christmas” present.

Thank you for your kindness.

(Michael C. Grant) #14

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?

(Michael C. Grant) #15

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.

Cvx_setup error
(Royi) #16

Hi Michael,

It seems to work (MATLAB R2016b).

Thank You.

(Michael C. Grant) #17

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.

(Royi) #18

@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.

(Michael C. Grant) #19

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.

(Royi) #20


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.