How to compute the sum of the squares of all integers from 2 to 20 using for-loop?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys i am very new to MATLAB and i am currently in a class and need help with homework! thank you in advance!
1 comentario
Respuestas (1)
Prasanna Venkateshan
el 7 de Jul. de 2020
Editada: Prasanna Venkateshan
el 7 de Jul. de 2020
The variable sum contains your output
sum=0; for i=2:20 sum=sum+i^2; end disp(sum)
1 comentario
Image Analyst
el 7 de Jul. de 2020
Yes, but sum() is a built-in function that you should not destroy by calling your variable sum. Choose another name, like sumOfSquares or something.
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!