Finding the Sum of a Finite Series

39 vues (au cours des 30 derniers jours)
Agnieszka Polak
Agnieszka Polak le 6 Déc 2019
Hello,
I am trying to calculate the sum of a series. I am trying to use a while loop, however, I keep getting stuck. Any ideas how to proceed?
Thank you

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 6 Déc 2019
Modifié(e) : KALYAN ACHARJYA le 6 Déc 2019
No need any loop, just check here
Still having trouble, let me know?
  1 commentaire
Agnieszka Polak
Agnieszka Polak le 6 Déc 2019
Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (1)

Turlough Hughes
Turlough Hughes le 6 Déc 2019
Modifié(e) : Turlough Hughes le 6 Déc 2019
Here I just use some examples for x,y and n, and also instead of 'i' I used 'c' as 'i' is designated for complex numbers.
c=1; x=3; y=4; n=4;
addends=zeros(n,1)
while c<=n
addends(c)=(x*y)^c
c=c+1;
end
sum(addends)
addends are just the parts that will then be added together after the loop using the sum function.
Alterantively you could also just do this:
x=3; y=4; n=4;
sum((x*y).^[1:n])

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by