yang-En, haven't heard from you. If the vectorized approach above is to confusing to you then try this simple and intuitive for loop. It basically uses the "continue" command to skip interations where j = k.
numPoints = 3;
lambda = randi(9, 1, numPoints)
f = randi(9, 1, numPoints)
h = randi(9, 1, numPoints)
K = length(lambda)
outerSum = 0;
for k = 1 : K
innerSum = 0;
for j = 1 : length(h)
if j == k
continue;
end
innerSum = innerSum + h(j) * f(k);
end
outerSum = outerSum + lambda(k) * innerSum;
end
outerSum
Best Answer