MATLAB: Double sum with upper limits

MATLABsum

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 67×120 array.
Any suggestions would be appreciated 🙂

Best Answer

s = (1:size(d, 1)).';
result = sum(sum(d .* cos(s))) / sum(cos(s));
Loops not needed, they're just a waste of time.
Related Question