title: Deleting empty rows in a 3D cell array in Matlab
body: <p>I have a large <strong>3D</strong> CELL ARRAY (x1) which I have to delete the empty rows.
  How can I do this?</p>
  
  <p>Example of my cell array (some pieces of the variable): </p>
  
  <pre><code>val(:,:,1) = 
  
  [20]    []    []    []    []    []    []    []
  [ 0]    []    []    []    []    []    []    []
  [ 0]    []    []    []    []    []    []    []
  []      []    []    []    []    []    []    []
  
  (...)
  
  val(:,:,42) = 
  
  
  [ 34225]    [   215]    [    0]    [   0]    [    0]    [    0]    [    0]    [    0]
  [ 85200]    [   545]    [    0]    [   0]    [    0]    [    0]    [    0]    [    0]
  [ 65074]    [   190]    [ 1000]    [   0]    [    0]    [    0]    [    0]    [    0]
  [ 81570]    [  1385]    [ 2475]    [   0]    [    0]    [    0]    [    0]    [    0]    
  [ 67236]    [   530]    [  365]    [   0]    [    0]    [    0]    [    0]    [    0]
  [ 61338]    [     0]    [  100]    [   0]    [    0]    [    0]    [    0]    [    0]
  []          []          []         []        []         []         []         []    
  []          []          []         []        []         []         []         []  
  []          []          []         []        []         []         []         []   
  </code></pre>
  
  <p>In this case, I want to exclude the 4th row of <code>(:,:,1)</code>, the three last rows from <code>(:,:,42)</code> and all the others from these variable.</p>
  
  <p>I've tried</p>
  
  <pre><code>x1(all(all(cellfun((@isempty,x1),2),:,:) = [];
  </code></pre>
  
  <p>But it gave me this following error:</p>
  
  <p>Error: Expression or statement is incorrect--possibly
  unbalanced (, {, or [.</p>
  
  <p>PS: I cannot use <code>"=="</code> because its a cell array.</p>
  
  <p>Thanks in advance</p>