title: Comparing area between two matrices with multiple points of intersection (MATLAB)
body: <p>I have two matrices that contain the points for the top boundaries of two jigsaw puzzles. I am trying to calculate the area contained between these two matrices (of unequal rows). They have multiple points of intersection. The picture below gives a better idea of what I'm trying to accomplish. The output should be a numerical value (of the total area highlighted in blue). If this is too difficult to achieve, is there a better way to compare matrices to see which ones "fit" the best?</p>
  
  <p>Un-Highlighted Picture
  <img src="https://i.stack.imgur.com/kvtTB.png" alt="Area Un-Highlighted">
  Area(in blue) that I am trying to calculate (numerical value)
  <img src="https://i.stack.imgur.com/Udzls.png" alt="Area Highlighted"></p>
  
  <p>The matrix values are below if it helps:</p>
  
  <p>Matrix 1:</p>
  
  <pre><code>     1     1
       2     2
       3     2
       4     2
       5     2
       6     3
       7     3
       8     3
       9     3
      10     3
      11     3
      12     2
      13     2
      14     2
      15     2
      16     2
      17     2
      18     2
      19     2
      20     2
      21     2
      22     2
      23     2
      24     2
      25     2
      26     2
      27     2
      28     2
      29     2
      30     2
      31     2
      32     2
      33     2
      34     2
      35     2
      36     2
      37     2
      38     2
      39     2
      40     2
      41     2
      42     2
      43     2
      44     2
      45     2
      46     2
      47     2
      48     2
      49     2
      50     2
      51     2
      52     2
      53     2
      54     2
      55     2
      56     2
      57     2
      58     2
      59     2
      60     2
      61     2
      62     2
      63     2
      64     2
      65     2
      66     2
      67     2
      68     2
      69     2
      70     2
      71     2
      72     3
      73     3
      74     3
      75     4
      76     5
      77     6
      78     7
      79     8
      79     9
      80    10
      80    11
      80    12
      80    13
      80    14
      80    15
      79    16
      79    17
      79    18
      78    19
      78    20
      78    21
      77    22
      77    23
      77    24
      76    25
      76    26
      76    27
      75    28
      75    29
      75    30
      74    31
      74    32
      74    33
      73    34
      73    35
      73    36
      73    37
      73    38
      72    39
      72    40
      72    41
      72    42
      72    43
      72    44
      73    45
      73    46
      73    47
      74    48
      75    49
      76    50
      77    51
      78    52
      79    53
      80    53
      81    54
      82    54
      83    55
      84    55
      85    56
      86    56
      87    57
      88    57
      89    57
      90    58
      91    58
      92    58
      93    58
      94    59
      95    59
      96    59
      97    59
      98    59
      99    59
     100    59
     101    59
     102    59
     103    59
     104    59
     105    59
     106    59
     107    59
     108    59
     109    59
     110    59
     111    59
     112    58
     113    58
     114    58
     115    58
     116    57
     117    57
     118    57
     119    56
     120    56
     121    56
     122    55
     123    55
     124    54
     125    53
     126    53
     127    52
     128    51
     129    51
     130    50
     131    49
     132    48
     132    47
     133    46
     133    45
     133    44
     133    43
     133    42
     133    41
     133    40
     133    39
     133    38
     132    37
     132    36
     132    35
     131    34
     131    33
     131    32
     131    31
     130    30
     130    29
     130    28
     130    27
     129    26
     129    25
     128    24
     128    23
     127    22
     127    21
     127    20
     127    19
     126    18
     126    17
     126    16
     126    15
     126    14
     126    13
     126    12
     126    11
     126    10
     126     9
     127     8
     128     7
     129     6
     130     5
     131     4
     132     3
     133     3
     134     2
     135     2
     136     2
     137     2
     138     2
     139     2
     140     2
     141     2
     142     2
     143     2
     144     2
     145     2
     146     2
     147     2
     148     2
     149     2
     150     2
     151     2
     152     2
     153     2
     154     2
     155     2
     156     2
     157     2
     158     2
     159     2
     160     2
     161     2
     162     2
     163     2
     164     2
     165     2
     166     2
     167     2
     168     1
     169     1
     170     1
     171     1
     172     1
  </code></pre>
  
  <p>Matrix 2:</p>
  
  <pre><code>   173     3
     172     3
     171     3
     170     2
     169     2
     168     2
     167     2
     166     2
     165     2
     164     2
     163     2
     162     2
     161     2
     160     2
     159     2
     158     2
     157     2
     156     2
     155     2
     154     2
     153     2
     152     2
     151     2
     150     2
     149     2
     148     2
     147     2
     146     2
     145     2
     144     2
     143     2
     142     2
     141     2
     140     2
     139     2
     138     2
     137     2
     136     2
     135     3
     134     3
     133     3
     132     3
     131     4
     130     4
     129     4
     128     5
     127     6
     127     7
     127     8
     126     9
     127    10
     127    11
     127    12
     127    13
     127    14
     126    15
     127    16
     127    17
     127    18
     127    19
     127    20
     127    21
     128    22
     128    23
     128    24
     128    25
     129    26
     129    27
     129    28
     130    29
     130    30
     130    31
     131    32
     131    33
     131    34
     132    35
     132    36
     132    37
     132    38
     133    39
     133    40
     133    41
     133    42
     133    43
     132    44
     132    45
     132    46
     131    47
     130    48
     129    49
     128    50
     127    51
     126    52
     125    53
     124    54
     123    54
     122    55
     121    55
     120    55
     119    56
     118    56
     117    57
     116    58
     115    58
     114    59
     113    59
     112    59
     111    59
     110    60
     109    60
     108    60
     107    60
     106    60
     105    60
     104    60
     103    60
     102    60
     101    60
     100    60
      99    60
      98    60
      97    60
      96    60
      95    59
      94    59
      93    59
      92    59
      91    59
      90    58
      89    58
      88    57
      87    57
      86    56
      85    56
      84    55
      83    55
      82    54
      81    54
      80    53
      79    52
      78    51
      77    50
      76    49
      75    48
      74    47
      73    46
      73    45
      73    44
      73    43
      73    42
      73    41
      73    40
      73    39
      73    38
      73    37
      73    36
      74    35
      74    34
      74    33
      75    32
      75    31
      75    30
      76    29
      76    28
      76    27
      77    26
      77    25
      77    24
      78    23
      78    22
      78    21
      79    20
      79    19
      80    18
      80    17
      80    16
      81    15
      81    14
      81    13
      81    12
      81    11
      81    10
      80    10
      79     9
      79     8
      78     7
      77     6
      76     5
      75     4
      74     4
      73     3
      72     3
      71     2
      70     2
      69     2
      68     1
      67     2
      66     2
      65     2
      64     2
      63     2
      62     2
      61     2
      60     2
      59     2
      58     2
      57     2
      56     2
      55     2
      54     2
      53     2
      52     2
      51     2
      50     2
      49     2
      48     2
      47     2
      46     2
      45     2
      44     2
      43     2
      42     2
      41     2
      40     2
      39     2
      38     2
      37     2
      36     2
      35     2
      34     2
      33     2
      32     2
      31     2
      30     2
      29     2
      28     2
      27     2
      26     2
      25     2
      24     2
      23     2
      22     2
      21     2
      20     2
      19     2
      18     2
      17     2
      16     2
      15     2
      14     2
      13     2
      12     2
      11     2
      10     2
       9     2
       8     2
       7     2
       6     2
       5     2
       4     2
       3     2
       2     2
       1     3
  </code></pre>