how to calculate Somme of vector elements ?

조회 수: 59 (최근 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 CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by