MATLAB: Plotting on multi figures

figureplot

I plot data to a figure using a function i have created(using code generation):
function createPlot(x1, y1, title)
figure1 = figure;
% Create axes
axes1 = axes('Parent',figure1,'YGrid','on','XGrid','on');
box(axes1,'on');
hold(axes1,'all');
% Create plot
plot(x1,y1,'LineWidth',2,'DisplayName','y1 vs. x1');
% Create textbox
annotation(figure1,'textbox',...
[0.170811320754717 0.777089783281734 0.237993710691824 0.111455108359134],...
'Interpreter','none',...
'String',{title},...
'FontSize',12,...
'FitBoxToText','off',...
'LineStyle','none',...
'Color',[1 0 0]);
I now write a script to run this for all files in a folder. How can i make each call of the createPlot function above to plot on a different figure

Best Answer

It should be opening a new figure each time you call it because of the 2nd line:
figure;
?
So just call it multiple times.