0001 function screen2png(file,res) 0002 set(gcf,'paperpositionmode','auto') 0003 set(gca,'xticklabelmode','manual','yticklabelmode','manual') 0004 0005 if ~exist('res') 0006 res=100 0007 end 0008 0009 set(gcf,'Units','pixels'); 0010 scrpos = get(gcf,'Position'); 0011 newpos = scrpos/100; 0012 set(gcf,'PaperUnits','inches','PaperPosition',newpos) 0013 eval(sprintf('print -dpng -r%d %s',res,file)) 0014