how to calculate Somme of vector elements ?

158 vues (au cours des 30 derniers jours)
diadalina
diadalina le 21 Oct 2018
Commenté : mohamed le 29 Mar 2024 à 13:56
i would like to calculate the somme k=1:10^5 of 1/k^2,using the command sum, can anyone help me ?

Réponse acceptée

madhan ravi
madhan ravi le 21 Oct 2018
Modifié(e) : madhan ravi le 21 Oct 2018
k=1:10.^5;
sum(1./(k.^2))
  6 commentaires
diadalina
diadalina le 28 Oct 2018
is there any method to verify the obtained result ?
Bruno Luong
Bruno Luong le 28 Oct 2018
Modifié(e) : Bruno Luong le 28 Oct 2018
"is there any method to verify the obtained result ?"
s = sum(1./(k.^2))
s / (pi^2/6)
That gives
s =
1.6449
ans =
1.0000
Seems alright to me.

Connectez-vous pour commenter.

Plus de réponses (1)

mohamed
mohamed le 28 Mar 2024 à 23:25
I need instructions that I write in MATLAB, to give me the result of this sum
  2 commentaires
DGM
DGM le 28 Mar 2024 à 23:49
Modifié(e) : DGM le 28 Mar 2024 à 23:52
Without knowing what x or t are:
x = something
t = something
n = 0:1000;
t1 = 1/(pi^2*(2*n + 1)^2);
t2 = pi*(2*n + 1)*(x - 1)/2;
U = 800*sum(t1*cos(t2)*exp(-0.3738)*(2*n + 1)^2*t)
mohamed
mohamed le 29 Mar 2024 à 13:56
Thanks dude, just forgot to mention that "x" changes from 0 to 2, and t is the time

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by