# How can i write this formula Convex optimization in CVX with MATLAB?

how can i express this formula with convex in matlab and s and q is vector(array) and lambda is row in matrix A and i want to minimize a and q

Have you read the CVX User’s Guide? The problem looks like it can be entered in CVX essentially as written, unless I am missing something, You’ll have to use appropriate for loops or indexing to make sure the constraints are imposed for the indicated indices; but I leave the details to you because it’s not apparent to me what all the indexing consists of, but it should be to you if you are implementing the model and have gained the requisite understanding of what the formulation is.

You will need to declare `q` as `complex`

1 Like

`q(152)` only specifies the 152nd element, not all the elements. Use `q` to refer to the entire vector.

Why are you using `==` for the 2nd constraint when it is `<=` ?

The first two constraints should be

``````s'*q == s'*s
q'*q <= a*s'*s
``````

I’ll let you handle the remaining constraints, because I don’t understand the notation, and it is not one of my life ambitions to understand it.

I think you need to re-read the CVX Users’ Guide, and perhaps try some example in it, then try modifying the example, before you try to work on your own problem. maybe you also need to brush up on MATLAB basics, such as how indexing works.

1 Like