title: Count number of occurrence of words in cell array of cell arrays and display the words in Matlab
body: <p>I have a first loop that stores in b the recalled words (meaning the words that correspond to a 1 in SUBJ.RECALL).</p>
  
  <pre><code>b=[]; 
  for s=1:length(SUBJ)
  for r=1:length(SUBJ(s).RECALL)
     words=SUBJ(s).WORDS{r};
   if max(SUBJ(s).RECALL{r}==1)
     b{s}{r}=(words(find(SUBJ(s).RECALL{r}))); 
   end
  end
  end
  </code></pre>
  
  <p>b{s}{r} displays the content of the last subject. b refers to all subjects and  is a 1x7 cell storing six 1x3 cells and one 1x2 cell. I would like to count the occurrence of the words contained in b and,if possible, also have the words displayed corresponding to each occurrence.
  I have tried several ways, but none is very efficient. 
  They are based in comparing pairs of subjects using ismember. The words are organized in different blocks and the order is randomized across subjects, that explains the different indexing in subject 1 and 2.</p>
  
  <pre><code>list1match=[]; %SUBJ1 %SUBJ2 
          s1l1=b{1}{1};
           l1=ismember(s1l1,b{2}{2});
           if max(l1)==1
              list1match=(s1l1(l1))
           end
           list1match=list1match(:);
           list1match=(horzcat(list1match,list1match));%SUBJ1 %SUBJ2  
           list1nomatch=setxor(s1l1,b{2}{2})
  </code></pre>
  
  <p>Is there a way to do it globally? Thanks in advance for any comment.</p>