title: How to apply a function on every pair of rows of a Matrix in Matlab?
body: <p>I'm new to matlab and working with matrix and I'm kinda confused.</p>
  
  <p>I'm supposed to make a <code>m</code> x <code>n</code> matrix called <code>M</code> and it's elements are <code>-1</code>, <code>1</code> and <code>0</code>.  </p>
  
  <p>I need to write a function called <code>d(x,y)</code> which returns <code>1</code> if <code>x = -1</code> and <code>y = 1</code>. And returns <code>0</code> otherwise.  </p>
  
  <p>and another function which calculates the sum of d(m(i,j),m(k,j)) in every column:</p>
  
  <p><a href="https://i.stack.imgur.com/hP9oN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hP9oN.jpg" alt="func"></a></p>
  
  <p>Please read the comment for an example.</p>
  
  <p>How to find the sum?</p>
  
  <p>I know basic programming but I don't know how to do this. </p>