MATLAB Answers

Double sum of a product

60 views (last 30 days)
Elia Guerra
Elia Guerra on 26 Apr 2018
Commented: James Tursa on 30 Apr 2018
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!

  0 Comments

Sign in to comment.

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

Elia Guerra
Elia Guerra on 30 Apr 2018
Thanks for your help!
Stephan
Stephan on 30 Apr 2018
with pleasure
Best regards
Stephan
James Tursa
James Tursa on 30 Apr 2018
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)

Tags

Products