how to add two sums by using loops?

what commond will be use for this ∑_(j=1)^5▒∑_(i=1)^2▒(i+j)

3 Comments

Why do you need loops? Vectorized code is neater, faster and more efficient:
rising falcon
rising falcon on 27 Oct 2015
Edited: rising falcon on 28 Oct 2015

how to solve it by using loops? ∑_(j=1)^5▒〖j+〗 ∑_(i=1)^2▒i

Stephen23
Stephen23 on 27 Oct 2015
Edited: Stephen23 on 27 Oct 2015
MATLAB has more efficient ways of doing many mathematical operations, without requiring loops. Read the link that I gave.
Can you please explain the syntax that you use to write the sum, or upload an image so we can see the original.

Sign in to comment.

Answers (1)

I didn't fully understand the question, but maybe you want a structure like
NI = 5;
NJ = 10;
sum = 0;
for ii=1:NI
for jj=1:NJ
sum = sum + 3;
end
end
Be aware that there are often vectorized methods that will be more efficient for calculation.

3 Comments

sumession veries from j=1 to 5 and i=1 to 2 and i want to add the i+j by using loops
Is this homework? I don't want to solve the whole problem for you. It should be VERY easy for you to adapt what I have written.
One thing to change is the name of the variable. Don't use sum because it's the name of an important built-in function.

Sign in to comment.

Categories

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

Tags

Asked:

on 27 Oct 2015

Commented:

on 29 Oct 2015

Community Treasure Hunt

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

Start Hunting!