I am trying to run this program but Error occur

“Too many outputs Arguments”

```
clear all
clc
% Generate data
dbar=[0 25 0 16 0;25 0 0 0 0;16 0 0 0 0;0 0 0 0 0;0 0 0 0 0];
w=[0 1 0 1 0;1 0 0 0 0;1 0 0 0 0;0 0 0 0 0;0 0 0 0 0];
one=ones(5,1);
% Create and solve problem
cvx_begin
variable G(5,5)
minimize(norm(dbar - (w.*(diag(G)*one'- 2*G + one*diag(G)')),'fro'))^2
subject to
G >= 0;
G*one == 0;
cvx_end
% Display results
disp( [ ' ans = ', sprintf( '%7.4f', G ) ] );
```

The error is due to squaring an entire `minimize`

statement, rather than just the argument of `minimize`

. To show it more clearly, presume there were a CVX variable `x`

. Then what you did is comparable to the statement `minimize(x)^2`

, which would produce the

Error using minimize

Too many output arguments.

error message. The correct way of minim9izing `x^2`

is `minimize(x^2)`

.

Now getting back to your problem, even if you made this fix, then in CVX 2.1, you would get an error message due to squaring `norm`

. So instead you should use `square_pos`

. But even better, just minimize `norm`

rather than its square, which may be better behaved numerically. To do that, just remove the `^2`

from your program, and it should execute correctly.

1 Like