i am counter a problem that matlab report as
Error using <= (line 22)
Disciplined convex programming error:
Invalid constraint: {real affine} <= {positive convex}

Hi. There is no need to address your question to individuals. Whoever can answer it will answer it.

Your problem is not a SOCP. Your first constraint type, ri <= norm( x-ai ,2) is going in the wrong direction to be convex. That is why you got an error message.

Also note that using vector variables will make your code simpler and easier to modify if you change the value of N. However you version is still correct (other than constraint type I mentioned going in the wrong direction).

@Mark_L_Stone Thank you very much!
The first constraint type whether I can covert into other type? such as change the equation or introduce other parameters for the constraint. I don’t understand the problem about the wrong direction well Thank you !

Convex expression <= affine is a convex constraint.
Convex expression >= affine, which is your first constraint type, is not a convex constraint.

So your problem, as formulated, is not a convex optimization problem. I am not saying whether or not your formulation is “correct” for the real world problem you are trying to model.