nxtile - a flexible, auto adjusting version of nexttile

nxtile accepts index or row,col positions for a tiledlayout grid and automatically adjusts the grid size if the given inputs do not fit.
Updated 16 Apr 2024

View License

nxtile works the same as nexttile, but with an option for users to give row,col inputs rather than a index, as well as automatically adjusting the tiledlayout grid size and copying the axes onto a new figure if the position or span does not fit the current grid.
If the grid size is expanded, the subscript row,col positions of axes remain constant, so an axis in position row 2, col 3 in a grid of 2x3 will remain in the row 2, col 3 position even if the grid is expanded to 20x30.
nxtile(myTiledLayout,2,3,[2,2]) % tile at row 2, col 2, with a span of 2 rows and columns in myTiledLayout
nxtile(10) % tile at index 10 of current (highest) tiledlayout in figure (gcf.Children)
nxtile(5,5) % tile at row 5, col 5, of current (highest) tiledlayout in figure (gcf.Children)
nxtile(myNestedLayout,2,[3,1]) % tile at index 2, with a span of 3 rows and 1 column in myNestedLayout
nxtile([4,8]) % tile at automatic nexttile position with a span of 4 rows and 8 columns
nxtile() % same as nexttile()
% Inputs:
% index (1,1) - index position of target tile
% or:
% row (1,1) double - row position of target tile
% col (1,1) double - col position of target tile
% span - a (1,2) double of the form [r c] (default [1,1]). The axes spans r rows by c columns of tiles.
% The upper left corner of the axes is positioned by row,col
% grid - TiledChartLayout object (default uses gcf.Children to access tiles object, will fail if multiple children)
% Outputs (in order):
% 1st - axes object
% 2nd - grid that matches the TiledLayout grid with matching indexes (just in case you wanted)...

Cite As

Luke Jenkins (2024). nxtile - a flexible, auto adjusting version of nexttile (https://www.mathworks.com/matlabcentral/fileexchange/163661-nxtile-a-flexible-auto-adjusting-version-of-nexttile), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes