% print current figure in "figures" folder
function graphsave(namepri,numfig,newfs)


g=ver;
b=struct2cell(g);
tmp=find_incell(b(1,:)','MATLAB');
if isempty(tmp)
tmp=0;
end
if ~exist('figures','dir')
    mkdir('figures');
end
if ~exist('namepri','var')
namepri=input('Give name to give to figure : ','s');
end
if nargin<2
numfig=input('Give number of figure');
end
% if nargin>1
% set (findall (figure(numfig), "-property", "fontsize"), "fontsize", newfs)
% else
if nargin<3
newfs=input('Change font size? (give size) ==> ');
end
if ~isempty(newfs)
set (findall (figure(numfig), '-property', 'fontsize'), 'fontsize', newfs)
end



if tmp
saveas(figure(numfig),['figures/',namepri,'.fig'])
orient(figure(numfig),'landscape')
if str2num(char(regexp(version,'(?<=R)[0-9]*','match')))>2014;
    print(figure(numfig),'-dpdf' ,'-fillpage',['figures/',namepri,'.pdf'])
else
     print(figure(numfig),'-dpdf', '-r100' ,['figures/',namepri,'.pdf']);
end
    print(figure(numfig),'-depsc2 ', '-r100',['figures/',namepri,'.eps'])
    print(figure(numfig),'-djpeg100 ',['figures/',namepri,'.jpeg'])
   
else
orient('landscape')
    print(figure(numfig),'-dpdf ', '-r100','-fillpage',['figures/',namepri,'.pdf'],'-r200')
    print(figure(numfig),'-depsc2 ','-r100',['figures/',namepri,'.eps'],'-r100')
    print(figure(numfig),'-djpeg100 ',['figures/',namepri,'.jpeg'])
end


    

return