MATLAB: Saveas (visible, off)

saveasvisible off

Hi I'm working on a script that creates a load of plots then saves them as individual fig files as well as all into a pdf file.
The problem I'm having is that although I've set visible to off, the plots still come up after going through the saveas function, so now I have to resort to using 'close all' after each graph. But even close all cause the graphs to flash up momentarily.
This is very annoying as I want the whole process invisible and not interfering with my desktop space.
Please help
Thanks
This is my script:
%%Throttle
i = i + 1;
figure(i)
set(gcf,'Visible','off','PaperOrientation',
'landscape','PaperPositionMode','manual','PaperPosition',[0.1, 0.1,30, 20]')
set(gca,'fontsize',10);
% Set Parameters to Plot
if exist('Accelerator_Pedal_Position'); plot(Elapsed_Time, Accelerator_Pedal_Position,'LineWidth', 1 ); else plot (0,NaN,'w'); end;
h=legend('Accelerator\_Pedal\_Position');
set(h,'fontsize',6);
% Set title for plot
title(['220HP'; 'Automated Manual';raw(3);'Throttle']);
%Set Labels for X and Y Axes'
xlabel ('Elapsed Time (s)');
ylabel ('Accelerator\_Pedal\_Positionn (%)')
xlim ([-inf inf])
grid on;
box on;
fpath = 'D:\Users\km933\Documents\MATLAB\Field Test v1';
saveas(figure(i), fullfile(fpath, 'Throttle'), 'fig');
print -dpsc -append myfile
close all

Best Answer

When you create your figure set the position to be off your screen, i.e.
'position', [10000 10000 800 600]
That way it wont be displayed on your desktop.