Borrar filtros
Borrar filtros

how to add two sums by using loops?

2 visualizaciones (últimos 30 días)
rising falcon
rising falcon el 27 de Oct. de 2015
Comentada: Image Analyst el 29 de Oct. de 2015
what commond will be use for this ∑_(j=1)^5▒∑_(i=1)^2▒(i+j)
  3 comentarios
rising falcon
rising falcon el 27 de Oct. de 2015
Editada: rising falcon el 28 de Oct. de 2015

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

Stephen23
Stephen23 el 27 de Oct. de 2015
Editada: Stephen23 el 27 de Oct. de 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.

Iniciar sesión para comentar.

Respuestas (1)

the cyclist
the cyclist el 27 de Oct. de 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 comentarios
the cyclist
the cyclist el 27 de Oct. de 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
Image Analyst el 29 de Oct. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by