title: Generating a sin wave to be saved in a .mif file in MATLAB
body: <p>I am trying to generate a sin wave that is <code>500Hz</code> for the first 5 seconds, then <code>1000Hz</code> to be saved in a <code>.mif</code> file in MATLAB. This is the general code I will be using to save the data to the <code>.mif</code> files, but I'm unsure how to properly generate the sin wave samples so that they can be included in this code. The sampling frequency will be <code>2000Hz</code>.</p>
  
  <p>Thank you.</p>
  
  <pre><code>fid = fopen('filename.mif','w');
  
  fprintf(fid,'WIDTH=16;\n');
  
  fprintf(fid,'DEPTH=256;\n');
  
  fprintf(fid,'ADDRESS_RADIX=UNS;\n');
  
  fprintf(fid,'DATA_RADIX=DEC;\n');
  
  fprintf(fid,'CONTENT BEGIN\n');
  
  for k = 1:256
  
    fprintf(fid,'%i : %i;\n',k-1,data(k));
  
  end
  
  fprintf(fid,'END;');
  
  fclose(fid);
  </code></pre>