Double sum with upper limits

2 Ansichten (letzte 30 Tage)
H Lange
H Lange am 2 Mär. 2020
Kommentiert: Luna am 3 Mär. 2020
Hi
I am trying to do the following calululation in matlab:
But I do not how how to do the two sums in the front. Our data (d) is a 67x120 array.
Any suggestions would be appreciated :)
  2 Kommentare
darova
darova am 2 Mär. 2020
Luna
Luna am 2 Mär. 2020
Bearbeitet: Luna am 2 Mär. 2020
What have you done so far as coding? And what is d?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Guillaume
Guillaume am 2 Mär. 2020
Bearbeitet: Guillaume am 2 Mär. 2020
s = (1:size(d, 1)).';
result = sum(sum(d .* cos(s))) / sum(cos(s));
Loops not needed, they're just a waste of time.
  3 Kommentare
Guillaume
Guillaume am 2 Mär. 2020
Yes, I made a mistake, there was a sum missing in the denominator. I assumed that the could be taken out of the double sum, i.e. it's over the whole range. It's not clear and we didn't get an answer to Darova's question. So, my code implement:
If it's a partial sum as you think, then:
s = (1:size(d, 1)).';
result = sum(sum(d .* cos(s) ./ cumsum(cos(s))));
which implements
Luna
Luna am 3 Mär. 2020
You are right.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Luna
Luna am 2 Mär. 2020
Maybe something like that would help:
d = rand(67,120);
sum_of_cos_s = 0;
result = 0;
for s = 1:67
for j = 1:120
sum_of_cos_s = sum_of_cos_s+cos(s);
result = result + (d(s,j)*cos(s))/sum_of_cos_s;
end
end

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by