have you tried using for each iteration
saveas(gca,'figure.jpg')
you would have to change the file name each time by adding a string with i and ii in the figure name.
filename = ['figure_',num2str(i),'_',num2str(ii),'.jpg'];
saveas(gca,filename)
Would this work ?