Subindex error for the class cvx

I am trying to do this but getting error

Error using subsindex
Function ‘subsindex’ is not defined for values of class ‘cvx’.

can anyone can help to get the reason pls.

cvx_begin
variables d(n+4)
minimize (d(n+1) + c/n^(1/p)*norm(d(1:n),p))
subject to

  • d(n+1) - group’*(xdata * d(n+2:n+3) - d(n+4)) <= d(1:n)
    d(1:n) >= 0
    norm(d(n+2:n+3),2)= 1
    cvx_end

norm(d(n+2:n+3),2)= 1
is erroneous and what is causing the error message.

If you meant this as an equality constraint, you need ==, not =, i.e.,
norm(d(n+2:n+3),2) == 1

Unfortunately, that is not convex and will be rejected by CVX. However, if you mean it to be <=, then you’re in luck.

Thanks.

Actually I wanted to have squared norm so i changed it to

sum(w’*w)=1;

what do you think now?

I don’t know what w is, but you’re not going to be able to specify a nonlinear equality constraint in CVX.

If you need such an equality constraint, and you’re just doing a one-time solution, you could always specify it as a <= and see if equality happens to be satisfied, in which case you’re done. Or perhaps you can concoct some kind of penalty function, expressible in CVX, and the iterate on penalty parameter to get your desired solution.

Another approach, and I have NO idea if it will work (converge, and if so, to even a local minimum, and you can forget about guarantee of global minimum), is to use a <= constraint, and add a modified >= constraint, per stephen_boyd’s answer in How to handle nonlinear equality constraints? , and then iterate as per that answer.