Help coding max sum of capacity (max sum log_det)

I want to solve:

H(:,:,1) = randn(4,4)+1i*randn(4,4);
H(:,:,2) = randn(4,4)+1i*randn(4,4);
H(:,:,3) = .. "and so forth", more entries same as last two lines.
n = size(H,1);
l = -1*ones(n,1);
u = ones(n,1);

    variable x(n)
    maximize( sum(log_det(eye(n) + H*diag(x)*H')) )
    subject to
        l <= x <= u


but, sum(log_det(eye(n) + H*diag(x)H’)) is not a valid function. log_det(eye(n) + Hdiag(x)*H’) is fine, with H a 2D complex matrix.
I’m trying to encode something like this… basically I am working on a communications system, and need to take the sum of log_det’s, and maximize that. Cannot find the right commands to do that…
Help ?

What are you trying to sum over? If you have a separate objective function term (to be summed over terms) for each slice of H, you can build up the objective in a for loop, as follows:

variable x(n)
Objective = 0
for i = 1:number_of_slices_of_H
  Objective = Objective + log_det(eye(n) + H(:,:,i) * diag(x) * H(:,:,i)')
subject to
l <= x <= u

You can fix this up if is not exactly what you want.

Edit: I corrected the last multiplicative term in the Objective update to be
H(:,:,i) * diag(x) * H(:,:,i)' . Specifically, the 'for transpose should follow, not precede,(:,:,i)

Thanks, it worked!. I didn’\t realize I could build objective functions in a loop like that, powerful!