MATLAB: Double sum of a product

doubleMATLABsums

Can anyone help me with this? I've just started to use Matlab and i don't know how to do it. Thanks in advance!

Best Answer

Hi,
Use a nested for-loop for this. Outer loop counts up from i=1 to N and the inner loop from n=1 to N.
for n = 1:N
for k = 1:N
r_0 = sum(rho_kn * r_k0 * r_n0);
end
end
r_0 = sqrt(r_0);
Note:
I replaced "i" by "k" here, because you could get in trouble when using i for loop count in combination with complex numbers. So i isnt recommended to use as a variable in matlab code.
Best regards
Stephan