Failing to create an integer variable

I want to create an integer variable in my optimization problem, while Matlab raises the warning message:

Invalid matrix structure modifier: integer
Trying to declare multiple variables? Use the VARIABLES keyword instead.

My Matlab version is R2021a, and the solver is gurobi 9.5.0.
And my code is as follows, the warning message raises from the third line.

variable x(SVC_count+v_count+l_count+P_count+Q_count);
variable OLTC integer    
A_obj = [zeros(v_count, SVC_count), diag(ones(v_count, 1)), zeros(v_count,P_count+Q_count+l_count)];
b_obj = ones(v_count, 1);
minimize(norm(A_obj * x - b_obj))    

subject to
    p_A * x == p_rhs
    q_A * x == q_rhs
    v1_A * x == v1_rhs * (0.95 + 0.025 * OLTC)
    v_A * x == v_rhs
    SVC_A * x <= SVC_rhs
    SVC_A * x >= 0
    vmin_A * x >= vmin_rhs
    vmax_A * x <= vmax_rhs
    fai_A * x >= fai_rhs
    OLTC >= 0 
    OLTC <= 5
    for i = 1:l_count
        norm([l_A1(i, :)*x; l_A2(i,:)*x-10; l_A3(i,:)*x-10]) <= l_c(i, :)*x 
cvx_quiet true

Something is screwed up in your CVX installation or MATLAB session. That error should not occur if everything is installed correctly and nothing is corrupted.


  1. New MATLAB session
  2. Reinstall CVX. Make sure you are using CVX 2.2, not CVX 3.0beta
  3. If neither of those resolve the problem, see if anything is shown for which -all OLTC. Try changing OLTC to some other name.

Also, I recommend you not use cvx_quiet true until you have verified everything is working correctly.

My cvx version is ‘Redistributable: free solvers only - All platforms (v1.22)’. Is this a correct cvx version?
And is it possible that the variable function conflicts with other function that named after variable in other package?

Integer variables are not supported in that version, which is ancient. Hence the error.

Download CVX 2.2 from .