フィルターのクリア

How To Calculate Double Summation In Matlb

8 ビュー (過去 30 日間)
Pranjal Pathak
Pranjal Pathak 2012 年 8 月 31 日
Hi,
Can anyone help me in performing double summation of matrix elements using Matlab of the following equation:
Xc=[Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)*x]/[Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)]
Yc=[Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)*y]/[Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)].
Where: Sum represents summation,
I(i,j): Consider a 10x10 random matrix,
I(m): Middle element of the matrix I(i,j),
x & y: Co-ordinate of the matrix I(i,j),
H(i,j): H(i,j)=1; if I(i,j)>=I(m) 0; if I(i,j)<I(m).
Thanking You!

採用された回答

Dishant Arora
Dishant Arora 2012 年 8 月 31 日
編集済み: Dishant Arora 2012 年 9 月 3 日
first thing is, how would you define a middle element in a 10*10 array.
Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)}
Btw, look at the above statement carefully, what you are doing is nothing but multiplying corresponding elements of 2 matrices and then summing up all the elements.you can accomplish this by:
mat=(I-I(m)).*H.*x;
summation=sum(mat(:));
  2 件のコメント
Dishant Arora
Dishant Arora 2012 年 9 月 3 日
H=zeros(size(I));
H(I>=I(m))=1;
gives you H, you need not to use if else statement. it's a powerful feature of matlab called logical indexing. http://blogs.mathworks.com/steve/2008/01/28/logical-indexing/ check out this blog.
Image Analyst
Image Analyst 2012 年 9 月 3 日
Yeah, that's what I asked him in his duplicate: http://www.mathworks.com/matlabcentral/answers/47267-how-to-execute-if-else-statement What does middle element mean?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by