Use parentheses around the entirety of the objective function. Due to a quirk in CVX or MATLAB (I guess it could be called a feature), it is good practice to always do that when the objective has more than one term, although might not always be necessary.

Hi! I am running into a similar issue, and although I’ve tried the solutions already provided here, it seems that I still get the “Inner matrix dimensions must agree”

What I am trying to implement is the following constraint:

where miu1,k, miu2,k and z0,k are scalar inputs, while zk and sigm are one of the variables that I declared.

Additionally, I just allocated the substraction between the z terms in paranthesis as del_z = zk-z0k;
I wrote the constraint in the picture like this:

The last term on the LHS is 1 by 101 by 1 by 101, which is non-conformal, hence the error message. Perhaps you want del_z.^2/2 , which also could be written del_z.*del_z/2 .

Your use of many extraneous parentheses makes your code unnecessarily difficult to read. Although not responsible for the error message you encountered, it appears that the sign of the last term on the LHS is wrong, because it is insides parentheses preceded by a negative sign.