"Error using reshape"


(Sébastien Loisel) #1

Hi,

I’m trying to minimize a sum of norms. When I evaluate my objective outside the cvx_begin/cvx_end, it works fine, but when I try it inside the cvx_begin/cvx_end, I get a rather odd error message. What am I doing wrong?

Dx = randn(5,3); Dy = randn(5,3);
cx = randn(5,1); cy = randn(5,1);
p = 1.1;
cvx_begin
    variable u(3);
    minimize(sum(norms([Dx\*u+cx,Dy\*u+cy],p,2)));
cvx_end

Edit: here’s the output of the above:

Error using reshape
To RESHAPE the number of elements must not change.

Error in cvx/cat (line 102)
yb = reshape( yb, nz, psz );

Error in cvx/norms (line 89)
{ cat( 3, z, y( ones(nx,1), : ) ), cvx_accept_convex(x) } …


(Mark L. Stone) #2

This will work for p =1 or p = 2. Otherwise, you will need to reformulate per my 2nd answer at Minimizing sum of powers .


(Sébastien Loisel) #3

OK thanks very much!