How to write a for loop for summation?
Mostrar comentarios más antiguos
Is there another way to do summation without for loop, or how would I do it with a for loop?
I want to iterate from N = 1 to N = 25 with 0 < x < 2*pi of the equation n*(sin^2(x)+cos^2(x)) I'm not so sure how to do a for loop for the summation
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 6 de Feb. de 2018
0 votos
Use sum().
sin(x)^2 + cos(x)^2 = 1, even for complex numbers, so n*(sin(x)^2 + cos(x)^2) is going to simplify to n.
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!