Error "Undefined function 'vec' for input arguments of type 'double'

Dear all,

When I was using CVX, the code works on my desktop. But it does not work on another computer.
The problem I was try to solve is shown as below

variable x©
minimize (-labelTrain’trainDatax + sum(log_sum_exp([zeros(1,r); x’trainData’]))+ lambda sum(abs(x)./(sqrt(abs(beta))+ eps)));


CVX works with other objective functions on this computer.
Is there anything wrong with this computer?
The error information is as following:

Undefined function ‘vec’ for input arguments of type ‘double’.

Error in cvxprob/solve (line 244)
Anew2 = Anew * diag(sparse(vec(amult(orow,:))));

Error in cvx_end (line 88)
solve( prob );

Error in CptLambda (line 33)
Thank you for your time.

Please read the first half of the following thread and see if it helps you.

Here is the answer which hopefully will help you.

mcg Michael C. Grant A more permanent solution is to add the directory cvx/functions/vec_ to your MATLAB path (making sure of course to add the full path)!

Here’s what is going on. vec is a function that converts matrices into vectors. I have it privately defined for @cvx
objects, so that definition doesn’t conflict with anything else. But
it’s also useful for double-precision matrices as well. The problem is
that a lot of other packages define it as well. In order to avoid name
conflicts, I try to add my own version of vec.m only if it isn’t present already in your MATLAB path.

But for some reason, in a few cases out there, my cvx_setup script thinks it sees vec
in your MATLAB path when it’s not there. I really don’t know why that
is. I have simply been unable to reproduce this problem myself. If
someone could figure that out for me, I would be grateful.

1 Like