Double sum of a product

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!

 Accepted Answer

Stephan
Stephan on 26 Apr 2018
Edited: Stephan on 26 Apr 2018
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

3 Comments

Thanks for your help!
with pleasure
Best regards
Stephan
This can't possibly work correctly. r_0 is replaced with each iteration instead of accumulating. The indexes n and k are not used inside the loops for anything. Etc.
Have you actually tried to use this "solution"?

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Tags

Asked:

on 26 Apr 2018

Commented:

on 30 Apr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!