- Array Indexing - https://www.mathworks.com/help/matlab/math/array-indexing.html
- for - https://www.mathworks.com/help/matlab/ref/for.html
calling a matrix with indexing
20 views (last 30 days)
Show older comments
Dear all, I am not sure whether it is called inequality addition (for the sigma part) or anything, but I have to call the matrix to solve the equation. Here is the formula:

here is the variable: K=2; k=1:K; l=1:K, except l=k. for example:

Do you have any idea to generally write it in matlab? maybe using for or while function?
Thank you
0 Comments
Answers (1)
ag
on 2 Dec 2024
Hi Mei,
To implement the given formula, you can use a nested "for" loop as shown in the below code snippet:
% Compute Q_k for each k
for k = 1:K
sum_term = 0;
for l = 1:K
if l ~= k
% Compute the term for l != k
term = (P(l) / d(k)) * H(k, l, :) * F(l, :)' * F(l, :) * H(k, l, :)';
sum_term = sum_term + term;
end
end
Q(k) = sum_term;
end
For more details, please refer to the following MathWorks documentations:
Hope this helps!
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!