Why CVX behave like this?

I have a simple script like this

        variable   beta(n,1)
        variable   eta(n,1)
        variable   Y(n,1)
        variable   t
        minimize (t)
        subject to 
            eta    >=0
           beta   >=0
           [R_t,-beta+eta;(-beta+eta)',(c *t*-d) ]>=0

It gets an error in matlab, " undefined variable of type ‘char’ ’ about variable eta. After I removed the extra blank characters after eta and beta, like this eta>=0, beta>=0 , matlab no longer gets an error.
Am I doing something incorrectly or it is a defined behaviour of cvx?

This is very interesting. I am not exactly sure, but it might have something to do with the fact that beta is a function in MATLAB, so some sort of name conflict. That doesn’t explain eta, but perhaps you have a function called eta somewhere?

Anyway, try this: before cvx_begin, add these lines:

beta = 0;
eta = 0;

Now try your model again, with the spaces intact. Does it work then? This forces MATLAB to deduce that eta and beta are variables.

Sorry for the late reply. Actually, my variables are beta_t and eta_t. I made it simple for the purpose of the question.

Well, “keeping it simple” is a problem if it doesn’t help us identify the issue. For instance: which line in particular is causing the error? Perhaps the full error message text should be posted. What version of MATLAB are you running?

Yes. you are right. Lines eta >=0 and beta >=0 makes the error. Matlab version is R2014a.

Two things to try:

  • before cvx_begin, add the line eta = 0; beta = 0;
  • Outting spaces after the >= in each inequality; i.e., eta >= 0, beta >= 0.

CVX does weird things to make its models look natural, and sometimes it seems to confuse MATLAB’s parser. These are just tips to help it make the right choices.