how to perform summation operation

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 3일

0 개 추천

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

kash
kash 2012년 1월 3일
walter what is A
my values should be as A1,A2.....A10
A1is 1st value ,,,,so on
Walter Roberson
Walter Roberson 2012년 1월 3일
If your data is in separate variables, then Don't Do That.
http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
kash
kash 2012년 1월 3일
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 2012년 1월 3일
A = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10];
Now proceed with the code I showed above.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by