MATLAB: How to perform summation operation

summation

i have an equation
X=1/K summation i=i to k *(Ai ^2) where k=10…
please help

Best Answer

A1k = A(1:k);
A1k2 = A1k .^ 2;
sumA1k2 = sum(A1k2);
avgA1k2 = sumA1k2 / k;
In some situations the calculation could be reduced to
mean(A.^2)
By the way: if you just happen to be doing a variance or standard deviation calculation, then the division would normally be by k-1 rather than by k. See http://en.wikipedia.org/wiki/Bessel%27s_correction