how to perform summation operation

1 view (last 30 days)
i have an equation
X=1/K summation i=i to k *(Ai ^2) where k=10...
please help

Accepted Answer

Walter Roberson
Walter Roberson on 3 Jan 2012
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
  4 Comments
kash
kash on 3 Jan 2012
A = zeros(1,10); % Not necessary, just much faster
for i=1:10
A(i) = % some equation
end
what equation i must write in A(i)
Walter Roberson
Walter Roberson on 3 Jan 2012
A = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10];
Now proceed with the code I showed above.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!