how to calculate Somme of vector elements ?

56 ビュー (過去 30 日間)
diadalina
diadalina 2018 年 10 月 21 日
コメント済み: mohamed 2024 年 3 月 29 日
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 日
Thanks dude, just forgot to mention that "x" changes from 0 to 2, and t is the time

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeJust for fun についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by