Matlab cvx : Invalid quadratic form(s): not a square

How can I realize the v*v’ in CVX?where v is a vector and also the variable of CVX, I met the problem in the picture. Thank you!!

use sum_square(). pls read the cvx user’s guide

Thanks! I will have a try.

But the result I want is a matrix, v*v’,where v’ is the ranspose matrix of v, sum_square caculate a value.

Reformulate
trace(Z'*H*v*v'*H'*Z)
as
square_pos(norm(v'*H'*Z,'fro'))

I don’t think you will need to bother with the real.

Thanks a lot! The problem is solved.
I need the result to be a real number,so I use real.
So would you tell me how can i realize it.?

take the picture below for example, the MSEk,j is real,but the matrixs are complex.

It will be real, according to math. Just do the Conjugate transpose of the formula in this picture, it will stay the same.

Oh,Yes! It is naturally real. Thanks

The output of norm will be real, with no possibility of roundoff level imaginary term. On the other hand, a Hermitian semidefinite quadratic form could potentially have a roundoff level imaginary term (which CVX might “object” to), especially if there are multiple non-parenthesized multiplications, even though in exact arithmetic, the imaginary component would be exactly zero.

Yes, though the MSE is real in arithmetic, when I use MSE in CVX object, it says"Error using cvxprob/newobj (line 43)Expressions in objective functions must be real."

So what should I do with MSE?Would you please give me some advice?

If you have an expression which is real, except for roundoff level imaginary term, you can apply real to it. Or you can do something like X = W*V, u'*X'*X*u instead of u'*V'*W'*W*V*u or just u'*(W*V)'*(W*V)*u

But why are u'*H*v and v'*H'*u real (even if they were computed in exact arithmetic(, and therefore, why is MSE real?

Because if we conjugate transpose MSE, we can find the result eqaul to itself. if a+bi=(a+bi)’,b=0

(u’Hv)’=v’H’u, Their imaginary parts are offset when they are added。a+bi+a-bi=2a,so MSE is real. Is that right?

O.k. So apply real(...) to remove any roundoff level imaginary part.

1 Like