MATLAB: How to save the figure

image processingMATLABprogramming

i have some functions then i have
if true
figure(k)
end
each iteration i got one figure. now i want to save the every figure in a new directory. please help me

Best Answer

num_of_fig = 1;
fichier=fullfile('directory','filename') ;
if true
figure(k);
name = strcat('figure',num2str(num_of_fig ));
% save figure name as figure1,figure2,figure3
saveas(gcf,strcat(name,'jpg'));
num_of_fig = num_of_fig +1;
end