function print_fig(fig,filename,size)

if nargin <= 2
  size = [0 0 8 6];
end

figure(fig)
set(gcf, 'PaperPositionMode', 'manual'); 
set(gcf, 'PaperUnits', 'inches'); 
set(gcf, 'PaperPosition', size); 
print (gcf,'-djpeg',filename);
