SDP example help

I have an optimization problem that I know that it could be solved using SDP. The issue is I’m not familiar with the topic and the literature is a bit complicated. Is there a clean and fairly simple example that shows how to convert a problem into SDP notation with its implementation to be solved? It would be a great help. Also, for a problem with many variables, should all of them be in the X vector or we can have some variable out of the X vector?


CVX lets you declare as many scalar, vector, and matrix variables as you want, with whatever names you want. That is different than some optimization solvers which only allow a single vector variable.

Here are some SDP examples in CVX.

Thanks Dr.Mark for your reply.
Let’s say I have the following constraints (as an example of my problem. I have other similar constraints as well)


w,x,y and z are all variables. a and b are indices (like line a and line b)
. here means multiplied, so we have (x_a).(x_b) which means x of line a multiplied by x of line b. Since both are continuous decision variables, this is non convex as it it but as far as I know, a SDP relaxation can help here. Am I right?

How can I write these constraints using CVX?

That is not a CVX question. if you want to guidance on whether/how to relax to an SDP, perhaps seek help at or And if you do, it might benefit you to not be so mysterious, if your thought of using SDP relaxation is based on some specific article or book you read.