MATLAB: How do you end a tiledlayout object

figurefunctionplottingtiledlayout

Im using a live script to generate multiple figures for a project and am using tiledlayout for some of the plots. Im running into the issue where after I call the function and use all the tiles, I am unable to generate normal plots again without explicitly generating a new tiledlayout object of size 1×1. Instead it will either overwrite the last plot of the tiledlayout or do some weird stuff. Is there anyway to stop the tiled layout?

Best Answer

Use figure to create a new figure window for plotting the next plot.
Live scripts will continue to use the same figure for all plotting unless you explicitly create a new one. If you use section breaks, what you see in each section are snapshots of the same figure, rather than new figures (unless you've created it with figure).
tiledlayout(1,2);
[X,Y,Z] = peaks(20);
% Tile 1
nexttile
surf(X,Y,Z)
% Tile 2
nexttile
contour(X,Y,Z)
% New plot
figure
x=1:5;
y=x.^2;
plot(x,y)