How to solve "Check for incorrect argument data type or missing argument in call to function 'vec'. "

When I try to solve my model by CVX, there is a confusing peoblem. And I really hope you can give me some suggestion.

The code is as fellow.
% obj = trace(inv(Je))
subject to
% for i = 1:Na+Nb
% Pi0(i) + deltaPi(i) <= P0
% Pi0(i) + deltaPi(i) >= 0
% end
sum(Pi0) + sum(deltaPi) <= P_total

Check for incorrect argument data type or missing argument in call to function ‘vec’.

Error in cvx/sparsify>replcols (line 142)
cvx___.readonly( ndxs ) = vec( cvx_readlevel( bN ) );

Error in cvx/sparsify (line 61)
[ x, forms, repls ] = replcols( x, tt, ‘full’, forms, repls, isobj );

Error in cvx_end (line 212)
x = sparsify( x, ‘objective’ );

Error in cvx/trace_inv (line 29)

Are you using CVX 2.2.? If not,switch to that. Otherwise, perhaps there is a conflict with a different version of vec in your MATLAB path.

Look at the output of
which -all vec

I have checked both the version of cvx and the output of ‘which -all vec’. The outputs are as fellow.
The error still exists :sob:

Try a new MATLAB session. Try reinstalling CVX. Try rebooting the computer. If none of those work, I am out of ideas.

well, I will try. Thanks a lot!

I don’t know if this is the case here but, for the record, all errors along the lines of

Check for incorrect argument data type or missing argument in call to function ‘vec’.

which I experience can be solved by completely removing all of YALMIP from the Matlab path. I’m not even sure if it has to do with vec itself, but maybe with something else that gets invoked from YALMIP first and then it causes the argument to vec to be wrong. I have no time to investigate it, but like I said starting Matlab without any YALMIP in the path always seems to help.

1 Like

I always put all CVX directories ahead of YALMIP directories in my MATLAB path. I determined many years ago that this was a good thing to do, although I don’t remember specifically about whether the item @Michal_Adamaszek pointed out was a contributing factor to my assessment.

And I remove CVX’s version of geomean.m and logsumexp.m, which are “useless” functions which announce that the correct CVX versions are geo_mean (and log_sum_exp), and then call those correct functions. Keeping CVX’s geomean and logsumexep would mean (if CVX is ahead of YALMIP in the MATLAB path) they cut in front of YALMIP’s versions, which would cause YALMIP to in effect call CVX’s versions (geo_mean and log_sum_exp) which would cause error messages or wrong results in YALMIP.

Do this combination of two things, and there will not be any conflicts I am aware of between CVX and YALMIP.