Only scalar quadratic forms can be specified in CVX toolbox

My guess is that you have the square from the Signal Processing Toolbox installed, and that is getting called by CVX’s square_pos instead of CVX’s square (see 2nd to last paragraph below for explanation).

On my machine,
which -all square_pos
C:\cvx_2.2.2\functions\square_pos.m
C:\cvx_2.2.2\functions@cvx\square_pos.m % cvx method

The first of these is supposed to be called when called with a numeric argument, whether or not interspersed between other CVX statements. You can look at the source code and see that it is basically returning square( max( x, 0 ) ), which would explain your results if the “wrong” square is being called.

The second of these is called for CVX expression (or CVX variable) argument. This does not use square, and perhaps is doing the “correct” thing for CVX, despite your having a non-CVX square. The code I suggested in my preceding post would be using this version of square_pos, because its argument is a CVX expression.