how to add two sums by using loops?
Ältere Kommentare anzeigen
what commond will be use for this ∑_(j=1)^5▒∑_(i=1)^2▒(i+j)
3 Kommentare
Stephen23
am 27 Okt. 2015
Why do you need loops? Vectorized code is neater, faster and more efficient:
rising falcon
am 27 Okt. 2015
Bearbeitet: rising falcon
am 28 Okt. 2015
Antworten (1)
the cyclist
am 27 Okt. 2015
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 Kommentare
rising falcon
am 27 Okt. 2015
the cyclist
am 27 Okt. 2015
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.
Image Analyst
am 29 Okt. 2015
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.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!