how to make sum of same elements in binary matrix
    2 ビュー (過去 30 日間)
  
       古いコメントを表示
    
hello. how to make sum of same elements in binary matrix by using "for"? code that a made makes only sum of true elements. i want to make sum of all elements...
if true
  function SumE = compare( BW1 , BW2 )
for a=1:110
  for b=1:110
      if (BW1(a,b)==BW2(a,b))
          SumE=SumE+1;
      end
  end
end
end
end
2 件のコメント
採用された回答
  Jan
      
      
 2014 年 3 月 22 日
        Your function counts the number of elements, which have equal value in both matrices. There is no test, if the elements are TRUE or FALSE. Therefore I do not understand the relation between the question and the code.
A simplified version of your program:
function SumE = compare(BW1, BW2)
SumE = sum(BW1(:) == BW2(:));
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Matrices and Arrays についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


