HELP! Undefined function ‘vec’ for input arguments of type 'double’

I’m using cvx on matlab (linux OS).First,i ran cvx_setup.m and cvx_startup.m, then,i ran my own codes. this probelm came up:

Error in cvx_opt/quad_form (line 43)
v=vce( v );

It’s strange because i have run the code on Win7 OS after installing a cvx.

In addition, file path (linux OS):
(directory where starting a matlab) /home/lisen/linux_IKC
(cvx) /usr/local/MATLAB/R2011b/cvx

my steps (In /home/lisen/linux_IKC):
1,run /usr/local/MATLAB/R2011b/cvx/cvx_setup
2,run /usr/local/MATLAB/R2011b/cvx/cvx_startup
3.mycode

who can help me???

Try changing that line to v=v(:).

What version of CVX are you running?

thank you for your replying. The version is cvx-a64.tar.gz.
I will try.

I’m sorry, what I mean is this: are you running CVX 2.1 or CVX 3.0 beta…

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.

Thank you very much! As you said, after adding the directory cvx/functions/vec_, it works.

1 Like

hi, my friend. I have a problem now hopeing you can help me:

Status: Failed
Optimal value (cvx_optval): NaN

this is my result using cvx. Now i want the result “NaN” as criterion. The objective function is
minimize(b’*x) where b=[0 0 0 1]. But when i ran the code “disp(num2str(x(4)));” the result is 619.4308. I don’t know why. Thank you!

I don’t really understand what you are saying. The solver failed, as you can see. You should not trust any of the values returned.

OK, What i mean is that i want the solver’s state as a criterion. So i can decide what to do next. In my precedur, i get the objective value as the criterion. As you can see, the optimal value is NaN. For the outer layer, the criterion is
if isfinite(d)==0 % d is the solver’s result
disp(num2str(d));
break;
end

In addition, it displays 619.4308 in the console. I really don’t know why. Could tell me how can i get the state of the solver.

Look at cvx_optval, which will be NaN in that case, and cvx_status. See this.

Thank you. I think i know why it displays 619.4308. In my code, i set b=[0 0 0 1] and minimize(b’*x). When cvx is over, it runs “d=b’*x” .but “x” is a intermediate result and not a correct result when cvx’s state is failed. and this is why i can’t get
correct objective value. So, i rewriting the code “d=cvx_optval”.