Mini - do you want to save the figure to a fig file or to some other data type? If the former, then you would use savefig, and if the latter you would use saveas. As for running your program fifty times, you could do something like this numIters = 50;
for k=1:numIters
close gcf;
filename = sprintf('myFigure%d.fig',k);
savefig(gcf,filename);
end
Note how we create a unique filename on each iteration of the for loop. You can modify the above to use the saveas function instead, or to specify a different file name and/or folder for that file.
Note how we use gcf which gets the current figure handle which will be the one that your program just created.
Best Answer