Hi, so I was creating this script on cvx

function [D,E] = DEcvx(cxx_final,cyy_final,cxy_final,Dw,lambdas1)

[rows columns] = size(Dw);

cvx_begin quiet

variable D(rows,columns) nonnegative

variable E(columns,rows) nonnegative

expressions val1 val2 val3 val4

for i=1:columns

for j=1:columns

summ = 0;

for k=1:rows

summ = summ + E(i,k)*D(k,j);

end

val1(i,j) = summ;

% val1(i,j) =E(i,:)*D(:,j);

end

end

for i=1:columns

for j=1:columns

val2(i,j) = val1(i,:)*cxy_final(:,j);

end

end

for i=1:columns

for j=1:columns

val3(i,j) = val1(i,:)*cxx_final(:,j);

end

end

val1_t = val1’;

for i=1:columns

for j=1:columns

val4(i,j) = val3(:,j)*val1_t(i,:);

end

end

minimize trace(cyy_final - 2*val2 + val4)+lambdas1*sum(E(:))+lambdas1*sum(D(:))

subject to

D >= 0

E >= 0

for i=1:columns

sum(D(:,i))==1;

sum(E(i,:))==1;

end

cvx_end

As you can see, I am trying to multiply some matrices, but using for loops as a workaround since cvx can only take scalar quadratic forms. but I get the error “Invalid quadratic form(s): not a square.” in line “summ = summ + E(i,k)*D(k,j);” in the 1st for loop.

Any help would be greatly appreciated. Thanks