Filter löschen
Filter löschen

how to calculate Somme of vector elements ?

57 Ansichten (letzte 30 Tage)
diadalina
diadalina am 21 Okt. 2018
Kommentiert: mohamed am 29 Mär. 2024
i would like to calculate the somme k=1:10^5 of 1/k^2,using the command sum, can anyone help me ?

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

mohamed
mohamed am 28 Mär. 2024
I need instructions that I write in MATLAB, to give me the result of this sum
  2 Kommentare
DGM
DGM am 28 Mär. 2024
Bearbeitet: DGM am 28 Mär. 2024
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 am 29 Mär. 2024
Thanks dude, just forgot to mention that "x" changes from 0 to 2, and t is the time

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by