clear;y=zeros(4,256);
%% m file to compute the 4 functions in the FFT-File lab
x=0:255;                     %% all have length 256
y=zeros(4,256);
y(1,:)=round(2^12); 
y(2,:)=round(2^12*sin(6*2*pi*x/256));
y(3,:)=round(2^12*sin(12*2*pi*x/256)/2);
y(4,:)=round(2^12*sin(18*2*pi*x/256)/3);
%%%%%%%%%%%%%%% Plot the 4 functions %%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:4
  subplot(2,2,k)
  stairs(x,y(k,:),'k-');
  switch k 
      case 1, title('lut0:0 KHz sine');
      case 2, title('lut1:6 kHz sine');
      case 3, title('lut2:12 kHz sine');
      otherwise title('lut3:18 i.e., 18 kHz sine');          
  end
  if min(y(k,:))>0
    axis([0 255 0.9*min(y(k,:)) 1.1*(max(y(k,:)))]);
  else
    axis([0 255 1.5*(min(y(k,:))) 1.5*(max(y(k,:)))]);
  end;
  str=sprintf('lut%d.mif',k-1); fid=fopen(str,'w');
  fprintf(fid,'depth= 256;\r\nwidth = 16;\r\n');
  fprintf(fid,'address_radix = dec;\r\ndata_radix = dec;\r\n');
  fprintf(fid,'content \r\nbegin\r\n');
  xy=[x; y(k,:)];
  fprintf(fid,'%d : %d;\r\n',xy);
  fprintf(fid,'end;\r\n');
  fclose('all');
end;
print -djpeg90 fun4fft.jpg