title: Write binary number to text file [MATLAB]
body: <p>I want to create an input file with random 8 bit binary number for VHDL testbench using Matlab. </p>
  
  <pre><code>%create random 10 decimal number
  a = randi ( [0 255], 10 , 1 ); 
  display(a);
  %convert to 8bit binary
  a=dec2bin(a,8);
  display(a); 
  %write to textfile
  fid=fopen('eventsIn.txt','wt'); 
  fprintf(fid,'%s\n',a); 
  fclose(fid);
  </code></pre>
  
  <p>how i want to make sure that the output become</p>
  
  <pre><code>1010100
  1100100
  0010100
  0111101
  0000110
  </code></pre>
  
  <p>instead of this format?</p>
  
  <pre><code>10101001100100001010001111010000110010011110111000101011101101101110100100100010
  </code></pre>