title: find the intersection of two array structs in Matlab
body: <p>How can I find the following intersection of two array structs in Matlab.</p>
  
  <p>For example, I have two struct arrays <code>a</code> and <code>b</code>:</p>
  
  <pre><code>a(1)=struct('x',1,'y',1);
  a(2)=struct('x',3,'y',2);
  a(3)=struct('x',4,'y',3);
  a(4)=struct('x',5,'y',4);
  a(5)=struct('x',1,'y',5);
  
  
  b(1)=struct('x',1,'y',1);
  b(2)=struct('x',3,'y',5);
  </code></pre>
  
  <p>I want to find the intersection of <code>a</code> and <code>b</code> as follows:</p>
  
  <pre><code>c = intersect(a,b)
  </code></pre>
  
  <p>where <code>c</code> should be</p>
  
  <pre><code>c = struct('x',1,'y',1);
  </code></pre>
  
  <p>But when it seems wrong when I type <code>intersect(a,b)</code> since the elements of <code>a</code> and <code>b</code> are both structures. How can I combat this difficulty. Thanks.</p>