title: Matlab - Writing Text and Numeric Data to a File in a Loop
body: <p>I have googled many times to solve my peculiar situation about writing/output to file without much success.</p>
  
  <p>I have a for loop which generates me 1 cell matrix and 1 regular matrix. For each loop the Cell Matrix can be of variable length. Assuming dimentions of &lt;1x5>, the cell matrix stores the following strings:</p>
  
  <pre><code>Aggregated Day, AggreVal from Curve, Val3_Name, Val4_Name, Val5_Name
  </code></pre>
  
  <p>The cell matrix can have different content and size for next loop.</p>
  
  <p>The numeric matrix is of same size as cell matrix and represents the values corresponding to names in cell matrix. Hence, for this loop it has size 1x5 and stores values as:</p>
  
  <pre><code>1.3, 1300, 14, 15, 16
  </code></pre>
  
  <p>I want to write the above cell and numeric matrix to ONE single file (preferrably excel or txt file for future manipulation) as they are being generated. First I want to output the cell matrix and right after that numeric matrix. Followed by cell matrix of second loop and so on.</p>
  
  <p>I remember it being very easy to do so in C++ by opening the file in append mode, but it appears to be tricky here in Matlab. I have tried playing with xlswrite, dlmwrite, xlsappend, etc but nothing has worked so far.</p>
  
  <p>Hence, the output file will look something like:</p>
  
  <pre><code>Loop1
  Aggregated Day, AggreVal from Curve, Val3_Name, Val4_Name, Val5_Name
  1.3, 1300, 14, 15, 16
  
  Loop2
  Aggaed Dy, AgeVal fm Curve, China, Val4_Name, Brazil
  1.453, 1300, 1774, 1115, 1613
  </code></pre>
  
  <p>Thanks</p>