```
clear all
clc
% Generate data
dbar=[0 41 5;41 0 0;5 0 0];
w=[0 1 1;1 0 0;1 0 0]; %%%% mask Matrix
one=ones(3,1);
% Create and solve problem
cvx_begin
variable G(3,3)
minimize (norm(dbar - (w.*(diag(G)*one'- 2*G + one*diag(G)')),'fro'))
subject to
G >= 0;
G*one == 0;
cvx_end
```

Output

G =

1.0e-09 *

```
0.4323 0.3402 0.3746
0.3384 0.4283 0.3786
0.3704 0.3760 0.3802
```

value of G is too small i am confuse is cvx is working correctly or not?

CVX produces `Status solved’, so it claims the problem is solved.

The optimal solution you show is within solver tolerance of all zeros, i.e., the zero matrix is the optimal solution,.

Your problem is enforcing all elements of G are nonnegative. If you really want that to be a semidefinite constraint instead, then ise `cvx_begin sdp`

and `variable G(3,3) symmetric`

and the resulting optimal G is not the matrix of all zeros, and the optimal objective value is essentially zero, rather than 58.4 in your version.

clear all

clc

% Generate data

dbar=[0 144 0;144 0 144;0 144 0];

% Mask Matrix

w=[0 1 0;1 0 1;0 1 0];

one=ones(3,1)

% Create and solve problem

cvx_begin sdp

variable G(3,3) symmetric

minimize (norm(dbar - (w.*(diag(G)**one’- 2*G + onediag(G)’)),‘fro’))

subject to

G >= 0;

G*one == 0;

cvx_end

% Display results

disp( [ ’ ans = ', sprintf( ‘%7.4f’, G ) ] );

G

Output

G=

79.9038 -16.0241 -63.8797

-16.0241 32.0481 -16.0241

-63.8797 -16.0241 79.9038

After solving i am getting G in symmetric from but still it does not satisfying second constrain

G*one == 0;

when i multiply G with one (column vector) it does not give vector of zeros instead it returns value

1.0e-11 *

-0.4590

-0.0043

0.7944

A vector with all entries of order 1e-10 is for all practical purposes the zero vector. See https://docs.mosek.com/modeling-cookbook/practical.html#the-quality-of-a-solution

yes you are right but i am using dbar = [0 144 0;144 0 144;0 144 0] in approximation function minimize (norm(dbar - (w. *(diag(G) **one’- 2* G + one diag(G)’)),‘fro’)) it is obvious that value of G which minimize this function is

G = [ 16 -32 16

-32 64 -32

16 -32 16]

but instead i am getting

G =[79.9038 -16.0241 -63.8797

-16.0241 32.0481 -16.0241

-63.8797 -16.0241 79.9038]

this difference is quiet large.

Your problem has a whole space of solutions with objective 0 and you are not guaranteed which one the interior point algorithm will converge to. For example I get

G =

52.7248 -22.8188 -29.9059

-22.8188 45.6376 -22.8188

-29.9059 -22.8188 52.7248

which is just as good.

@Michal_Adamaszek can you tell me how to find this whole space of solutions?

This is getting off-topic, but the condition G*one=0 together with the two equations you will get by setting the two entries of the objective matrix equal to the respective entries in dbar, that gives 5 linear equations in 6 variables.