title: Read text file content into matrix based on condition
body: <p>I have a text files of this format: </p>
  
  <pre><code>Food
  Fruits1     [heading]
      Apple    [value]
      Mango    [value]
      Orange   [value]
  Veg1        [heading]
      Potato   [value]
      Lettuce  [value]
  </code></pre>
  
  <p>I want to load this into <strong>Octave</strong> as a matrix of this format: </p>
  
  <pre><code>----------------------------------------------------------------------
  Item | Fruits1 | Apple | Mango | Orange | Veg1 | Potato | Lettuce
  ----------------------------------------------------------------------
       |         |       |       |        |      |        |         
  ----------------------------------------------------------------------
  </code></pre>
  
  <p>Hence, I need a matrix of size = 2x(n+m+1);  where n = number of [heading], m = number of [value].</p>
  
  <p>How can I use <em>fgetl</em> to read each line from the text file and store into a matrix satisfying the above condition? Any better ideas?</p>
  
  <p>Thanks!</p>
  
  <p>Edit: Code:- </p>
  
  <pre><code>fid = fopen('food.txt','r');
  num = 1;
    if (fid &lt; 0) 
      printf('Error:could not open file\n')
    else
      while ~feof(fid),
      line = fgetl(fid);
      arr=[line;];     
      num=num+1;
      end;
          fclose(fid)
    end; 
  </code></pre>