Lorentz Cone formulation

I use an SOC formulation I found in a cvx manual but keep getting some erro mesaage.

Do you know how I can solve this issue?

n = 40;
A = randn(20,n);
b = randn(20,1);
   variable x(n,1), y;
   subject to
      {A*x-b, y } == lorentz(n);
      y >= 0;

I think the main issue is the dimension of the Lorentz cone. Here’s a modification that works:

n = 40
m = 20
A = randn(m,n)
b = randn(m,1)
variables x(n) y
subject to
{A*x-b, y } == lorentz(m) % you had n here

Bien is correct. But why make things difficult on yourself? First of all, there is no need to add the constraint y>=0, because that is already enforced in the lorentz constraint. But more fundamentally, instead of using lorentz you can simply norm(A*x-b)<=y. It is exactly the same, mathematically, and easier to read. I definitely recommend avoiding the use of sets when functional alternatives like this exist.

So is there any situation in which you would recommend using the lorentz constraint?

I can’t think of one, no!