cvx_begin
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
cvx_end
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.
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?
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.