MATLAB: Save graph / plot progressively

plot graph progressively

Good evening, i need help, i want that my code saves plot in progressive mode. I thought to use saveas function in a code like this
f = figure('Visible', 'off');
plot(x,y,'r');
saveas(f,'figure_',num2str(numberofgraph,'%d'),'.jpeg');
but it doesn't work, it says "too many imput arguments"(i think it doesn't like
num2str(numberofgraph,'%d'),
How can i also decide where it has to save it? Thanks for your help

Best Answer

saveas(f,['figure_',num2str(numberofgraph,'%d'),'.jpeg']);