Error cvx_setup

I’m running MATLAB on MacBookPro. With my previous MATLAB version (2016a), cvx worked OK, but recently I installed the newest version of MATLAB and I tried to install cvx but I couldn’t. I have received the following error.

UNEXPECTED ERROR: -------------------------------------------------
Error using class
Cannot change the number of fields of class ‘cvx’ without first
typing ‘clear classes’.
Error in cvx (line 69)
v = class( struct( ‘size_’, s, ‘basis_’, b, ‘dual_’, ‘’, ‘dof_’, d,
‘slow_’, slow ), ‘cvx’, cvxobj );
Error in cvx_global (line 57)
temp = cvx( [0,1], [] );
Error in cvx_setup (line 180)
cvx_global;

Does this help? https://groups.google.com/forum/#!category-topic/yalmip/L8Xzsj0lm5I

No, I restarted MATLAB several times.

This suggests you have different versions of CVX installed on your computer somewhere. I suggest that you: 1) shut down all instances of MATLAB; 2) remove ALL copies of CVX from your computer (yes, completely remove them); 3) download a new copy of CVX; 4) install it according to the instructions.

I have removed MATLAB with cvx and installed it again. Then I have downloaded a new version of CVX 3.0 beta again and installed. But I still have problem. When I run the cvx_setup command, I will see the following lines which stop at “Testing with a simple model…” and after 10 min, the error message " Error in cvx/cvx_classify (line 4)
v = cvx_classify_mex( x.basis_, cvx___.classes );
Error in cvx/cvx_isvalid (line 6)
y = remap( cvx_classify( x ) );
Error in * (line 75)
if ~cvx_isvalid( z ),
Error in cvx_setup (line 261)
"
occurs (preceded by a lot of lines showing some files were missed).

cvx_setup


CVX: Software for Disciplined Convex Programming ©2014 CVX Research
Version 3.0beta, Build 1177 (e17eb8f) Thu Mar 30 22:00:17 2017

Installation info:
Path: /Users/Mahmoud/Downloads/cvx
MATLAB version: 9.2 (R2017a)
OS: Mac OS X x86_64 version 10.12.4
Java version: 1.7.0_75
Verfying CVX directory contents:
No missing files.
Loading preferences:
Global: /Users/Mahmoud/Downloads/cvx/cvx_prefs.mat … not found.
Local: /Users/Mahmoud/Library/Application Support/MathWorks/MATLAB/cvx_prefs.mat … loaded.
License host:
Username: Mahmoud
Host ID: f45c899ef5e9 (en0,2001:700:1501:a020:d09a:56c2:3f8b:cab0,2001:700:1501:a020:c2c:a0bc:ea97:5c25,128.39.200.115)
Installed license:
No license installed.
No valid licenses found.
Click here to fill out an academic license request
for the username and first hostid listed above.

Setting CVX paths…done.
Saving update path…done.
Searching for solvers…7 shims found.
2 solvers initialized (* = default):

(a lot of lines about missing files)

Error in cvx/cvx_classify (line 4)
v = cvx_classify_mex( x.basis_, cvx___.classes );
Error in cvx/cvx_isvalid (line 6)
y = remap( cvx_classify( x ) );
Error in * (line 75)
    if ~cvx_isvalid( z ),
Error in cvx_setup (line 261)
            minimize( norm(A*x-b,1) );
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Please report this error to support, and include entire output of
CVX_SETUP in your support request.

Please see the note on the download page about MATLAB R2017a.

Actually I fixed it myself after some trial and error. The issue is something related to the fact that MATLAB 2017 doesn’t compile the MEX files of CVX (I’m not sure if my sentence is technically right!). Then you have to run cvx_compile.m yourself and follow the printed results and message (I don’t really remember the other steps but it was straight forward, only by following the message you received after compiling). This worked for me.

That’s a good data point. In fact, CVX ships with the MEX files pre-compiled. It may be that they need to be recompiled for R2017a. But I’ve attempted to recompile them on some platforms and still have been unable to get them to work. I still recommend using an older version of MATLAB until we can truly support R2017a.