MATLAB: How to name multiple plots/subplots on a loop

plotssublotstitlexlabel

This loop plots 1 plot with 3 subplots on the same Figure ii times. I cannot figure out how though to label each of the 4 plot with a unique name as the loop progresses. I can use the title, but it only names one of the plots which leaves the other 3 in question to which they are.
for iv = mod((1:numel(k)),12)
k_i = k(iv);
figure (k_i)
DataAnalPlot([c(1:ii,k_i) p(1:ii,k_i)],[c(1:ii,k_i+1) p(1:ii,k_i+1)],[c(1:ii,k_i+2) p(1:ii,k_i+2)],[c(1:ii,k_i+3) p(1:ii,k_i+3)]);
end

Best Answer

First of all, don't use figure() in the loop - use subplot() instead. In the loop you can use sprintf() to build a caption, and then use title() to display it over the plot.
Assuming iv takes on the values 1, 2, 3, and 4:
subplot(2, 2, iv);
caption = sprintf('This is plot #%d', iv);
title(caption, 'FontSize', 20);