tiledlayout has additional features not supported in subplot. Changing subplot would cause backward compatibility issues.
Demo
Two blocks below produce nearly the same figure using tiledlayout and subplot while using as few lines as possible without sacrificing best-practices.
A subplot/tile will be added for each column of x but the number of columns of data are unknown!
Produce data
x = randn(200,n) .* (1./10.^[0:n-1]);
tiledlayout
tlo = tiledlayout(fig, 'flow');
arrayfun(@(col)histogram(nexttile(tlo),x(:,col)),1:n);
title(tlo,'Global title')
ylabel(tlo, 'Global ylabel')
xlabel(tlo, 'Global xlabel')
The arrayfun line is the same as this loop:
for i = 1:n
ax = nexttile(tlo);
histogram(ax, x(:,i));
end
subplot
The label placement took a long time to figure out relative to the tiledlayout example.
arrayfun(@(col)histogram(subplot(nRows,nCols,col),x(:,col)),1:n);
annotation(fig,'textarrow',[.15 .15], [.52 .52], ...
'String','Global ylabel',...
'HorizontalAlignment','Center',...
'VerticalAlignment','Middle',...
annotation(fig,'textarrow',[.6 .6], [.03 .03], ...
'String','Global xlabel',...
'HorizontalAlignment','Center',...
'VerticalAlignment','Middle',...
The arrayfun line is the same as this loop:
for i = 1:n
ax = subplot(nRows,nCols,i);
histogram(ax, x(:,i));
end