Hello, I’m working on a MATLAB project involving optimization using CVX for matrix operations.
I am trying to perform element-wise multiplication between subsets of two arrays t and q, which are dynamically indexed by another array other_indices. The error occurs at:
for k=1:K
other_indices = setdiff(1:K, k);
EH(k) = eta * h(k) * sum(t(other_indices) .* q(other_indices)) + …
eta * sum(t(other_indices).* p(other_indices) .* g(k, other_indices));
end
Both t and q are 1x5 double arrays. other_indices is calculated in a loop, excluding the current loop index k. It seems to produce a valid subset of indices, yet the multiplication throws a dimension mismatch error.
How could I solve this issue

