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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -