I need to create a vector Z in which the first element is:
col = 1:size(s, 2);
Z = sum(col .* s - col/N, 2);
Note that the sum 1/N + ... N/N could be extracted from the formula since it's a constant equal to (N+1)/2, so a simplification of the above would be:
Z = sum(col .* s) - (size(s, 2)+1)/2;
3 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566863
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566863
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566868
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566868
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566872
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/400263-how-to-make-a-summation-with-index-vector#comment_566872
Sign in to comment.