"Matrix dimensions must agree" error for scalar variable

I am trying to compare two scalar values, however, I reach “matrix dimensions must agree” error. The code is:

cvx_solver MOSEK
variable A(n,n,p) binary;
subject to
    for f=1:p
        sum(A(1,:,f))==sum(A(:,1,f))+1;
    end

The error:

Error using cvxprob/newcnstr (line 87)
Matrix dimensions must agree.

Error in  >=  (line 21)
b = newcnstr( evalin( 'caller', 'cvx_problem', '[]' ), x, y, '>=' );

Error in SolverForNew3R (line 19)
                sum(A(1,:,f))>=sum(A(:,1,f))+1;

Does anyone have any idea?

Your code segment looks correct. The error message looks strange to me, having >= rather than == . Are you sure the error message corresponds to the code segment you showed?

Try running a clean (new) MAT:LAB session, setting, n and p, then cvx_begin, then the code segment you showed. Do you still get this error message, including reference to >= ? If so, show the results of cvx_version.