How do I write a complicated objective function in cvx

The objective function which I try to minimize is


where R_pq is a known matrix but R_pq_po is

for i=1:length(array_x)
    for ii=1:length(array_y)
        for mm=m_min:m_max
            for nn=n_min:n_max

In it, array_x,array_y,M,N and A are all known matrix or array and x is a unkown variable(a matrix) which I try to achieve.
So, how can I write it in cvx? Would be grateful to any help!

Welcome to our community!!!

Have you proven this is convex? It looks rather dubious to me. If not for the imaginary argument of exp (is x real or complex?), perhaps R_pq_po coudl be calculated using CVX’s gp mode, but then you’d be out of luck trying to form the objective function. Unless and until you prove otherwise, I will mark this problem as non-convex.

Actually, I’m not sure whether it’s a convex problem, really sorry!
x is real but Imn is complex, therefore R_pq_po is complex.
The paper I followed actually use fminunc , a nonlinear progeamming solver of MATLAB , to solve this problem. But It needs gradient, which I don’t know how to calculate. So I just try cvx, maybe it can be solved by cvx.
So, how to make sure a problem is convex and what is gp mode. Sorry for my ignorance, if it’s not easy to answer such basic quesitions, I will do researches on my own.
Thanks for your answer!

It seems that you didn’t read the link I posted. CVX is not the right tool for your problem.

Beginning in MATLAB R2020b, when using the problem-based mode for the optimization toolbox, gradients are computed for you by Automatic Differentiation. Even if not, finite differences can be specified for gradient calculation. If you need further help on that, you should post at

Thanks again! I will read your link carefully!