How to assign values to CVX variable

How can I assign a value that is either zero or one (0,1) to a CVX variable?
for instance:
variable theta(i,j);
maximize (theta.*obj(i,j));
0 <= theta <= 1;

Use the binary keyword in your variable declaration. Then there is no need for 0 <= theta <= 1 .

CVX sees theta as an affine expression, hence when obj is concave, the product of obj and theta disobeys the DCP rule. Actually, theta is meant to be an indicator variable of either 1 or 0.

theta is meant to be an indicator variable of either 1 or 0.

That is what binary does.

As to any errors you are receiving, you are not showing your entire program. I don’t know what obj(i,j) is. Your objective function needs to evaluate to a real scalar, which it doesn’t unless i = j = 1.

Thank you very much for your timely response. I have done as advised and have the error message shown below.

i = j = 4;
cvx_solver Mosek
cvx_precision BEST
variables P(i,j)
variables theta binary
maximize (sum(sum(theta.*RATE)));
sum(theta.*P) <= Pmax

Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {concave}
Error in BETA_TEST01 (line 102)
maximize (sum(sum(theta.*RATE)));

PS: where RATE is cvx concave expression (4x4 matrix)

i = j = 4; is not legal in MATLAB.

What is RATE ? You must not be showing everything, because CVX thinks it is concave, rather than a constant (MATLAB variable).

sum(theta.*P) <= Pmax won’t be valid, either.