how to calculate Somme of vector elements ?

144 次查看(过去 30 天)
i would like to calculate the somme k=1:10^5 of 1/k^2,using the command sum, can anyone help me ?

采纳的回答

madhan ravi
madhan ravi 2018-10-21
编辑:madhan ravi 2018-10-21
k=1:10.^5;
sum(1./(k.^2))
  6 个评论
diadalina
diadalina 2018-10-28
is there any method to verify the obtained result ?
Bruno Luong
Bruno Luong 2018-10-28
编辑:Bruno Luong 2018-10-28
"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.

请先登录,再进行评论。

更多回答(1 个)

mohamed
mohamed 2024-3-28
I need instructions that I write in MATLAB, to give me the result of this sum
  2 个评论
DGM
DGM 2024-3-28
编辑:DGM 2024-3-28
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 2024-3-29,13:56
Thanks dude, just forgot to mention that "x" changes from 0 to 2, and t is the time

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by