Error using sparse

(Bence Meszaros) #1


I’m new to cvx. I’m trying to execute an example from “Disciplined Convex Programming” slides by Boyd and Grant.

cvx begin
variable Sigma(n,n) symmetric
maximize ( w'Sigma*w )
subject to
Sigma == semidefinite(n); % Sigma is positive semidefinite
Sigma >= L;
Sigma <= U;
cvx end

But I’m getting this error:

Error using sparse
sparse(A) does not accept char inputs A.  Use sparse(double(A)) instead.

Error in cvx (line 28)
            v = class( struct( 'size_', size( s ), 'basis_', sparse( s(:).' ), 'dual_',
            '', 'dof_', [], 'slow_', nnz( isinf( s ) | isnan( s ) ) ~= 0 ), 'cvx', cvxobj

I have:

>> whos w
  Name      Size            Bytes  Class     Attributes

  w         4x1                32  double              

>> whos L
  Name      Size            Bytes  Class     Attributes

  L         4x4               128  double              

>> whos U
  Name      Size            Bytes  Class     Attributes

  U         4x4               128  double              

>> whos n
  Name      Size            Bytes  Class     Attributes

  n         1x1                 8  double   

so everything is double. Could you please help me out? Thank you.

PS/Off topic.: What is this forum engine? I really like it.

(Mark L. Stone) #2

You are missing underscores. It should be cvx_begin and cvx_end
You already encountered the error message with your first line.

(Bence Meszaros) #3

Oh… I didn’t sport that! My bad. Thank you. I’ve also figured out the forum engine is Discourse 2.0.