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);
cvx_begin 
   variable x(n,1), y;
   minimize(y)
   subject to
      {A*x-b, y } == lorentz(n);
      y >= 0;
cvx_end

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)
cvx_begin
variables x(n) y
minimize(y)
subject to
{A*x-b, y } == lorentz(m) % you had n here
cvx_end

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!