title: How to write a structure to excel in MATLAB
body: <p>I have a structure which I want to write to excel file.</p>
  
  <p>For example, I want to write A which is structure to excel. A contains both textdata and numbers which I want to write to excel.</p>
  
  <pre><code>&gt;&gt; A.textdata
  
  ans = 
  
      Sheet1: {'Coco-Cola'  'CCE'}
  
  &gt;&gt; A.data
  
  ans = 
  
      Sheet1: [4 46.7100 46.2800 185.1200 -0.0092 -1.7200]
  </code></pre>
  
  <p>The output should be like this:
  <img src="https://i.stack.imgur.com/L6oHf.png" alt="enter image description here"></p>
  
  <p>Need some guidance on how to do it. </p>
  
  <p>What I have tried so far:</p>
  
  <p>1) <code>xlswrite(filename,A);</code></p>
  
  <p>It gave me this error: Error using xlswrite (line 166) Input data must be a numeric, cell, or logical array.</p>
  
  <p>2) <code>Acell = struct2cell(A);xlswrite(filename,Acell);</code></p>
  
  <p>It gave me this error:An error occurred on data export in CSV format. Caused by: Undefined function 'real' for input arguments of type 'struct'.</p>