corresponding intersection of two rows without zero in matlab -
i have matrix(m*n). every 2 rows, how can find number of corresponding elements not zero. example following rows: r1=[1,3,0,4] , r2=[5,0,0,4] ,the answer 2. because first , fourth elements in 2 rows not zero. thanks
you can use matrix multiplication:
l = logical(m); % convert matrix logical matrix result = l * l.'; % matrix multiplication compute number of corresponding elements
so matrix element result(i,j)
represents number of corresponding elements between row i
, row j
.
Comments
Post a Comment