Cvx variable(s) have been cleared or overwritten

Error using cvx_end (line 70)
The following cvx variable(s) have been cleared or overwritten:
This is often an indication that an equality constraint was
written with one equals ‘=’ instead of two ‘==’. The model
must be rewritten before cvx can proceed.

Error in Optimize_R (line 43)

cvx_begin sdp
cvx_precision high
variable rbar nonnegative;

rbar = min(R1, R2);                                                      %Auxilary Variable
maximize rbar;


Kindly suggest me what changes should I make to the code?

Your program has
variable rbar nonnegative;
rbar = min(R1, R2);
This latter statement makes rbar an (undeclared) expression, and overwrites the earlier variable declaration; hence the error message.

I think you only want the latter statement. if you want rbar to be nonnegative, add the constraint
rbar >= 0
somewhere after rbar = min(R1, R2);
Because the objective is to maximize rbar, that constraint would only serve to make the program infeasible if the maximum of rbar were negative, And would not affect the optimal solution if the maximum of rbar were nonnegative.

Declaration of scalar expressions is optional.

Thank you Sir.