MATLAB: Saving a figure in full screen size

save figure

Hello,
I am trying to save a matlab figure in PNG format, I wish to have a full screen size image. I have tried the following two scripts, in both cases the figure is visualized in full screen size, but the PNG file I get is smaller. Could anyone help me to fix this issue?
I thank you in advance. Giuseppe
figure('units','normalized','outerposition',[0 0 1 1])
plot([0,1], [0,1])
print('foos', '-dpng', '-r0');
or
figure; set(gcf, 'Position', get(0, 'Screensize'));
plot([0,1], [0,1])
print('foos', '-dpng', '-r0');

Best Answer

FigH = figure('Position', get(0, 'Screensize'));
F = getframe(FigH);
imwrite(F.cdata, 'Foos.png', 'png')