Populating a tiledlayout vertically rather than horizontally

Hi, I have an 1D array of images in a cell array.
I want to montage them using my own settings, so I have been using tiledlayout.
I must have 3 rows, and my total number of images is always a multiple of 3.
n=app.ImCount.Value; % number of images in my cell array
tcl = tiledlayout(3,ceil(n/3),'TileSpacing','none','Padding','compact'); %tight
for i=1:n
IM=app.imgArray{i};
ROI=imcrop(IM,rect);
ax=nexttile(tcl);
myImagesc(app,ax,ROI); axis(ax,'image');
end
Say I have 12 images, rather than have the layout like this:
1 2 3 4
5 6 7 8
9 10 11 12
I want this, i.e. populating vertically
1 4 7 10
2 5 8 11
3 6 9 12
I thought there might have been an option in the tied layout but there is only a complete "vertical" arrangement possible.
So my idea next is to just index the images like 1,4,7,10,2,5,8,11 etc, but have no idea how to do this or whether this is a good way anyway
Thanks

 Respuesta aceptada

Star Strider
Star Strider el 5 de Jun. de 2025
One option could be to use the TileIndexing property, and set it to 'columnmajor'.

6 comentarios

thats exactly what Im looking for, but didn't see it.
Thnaks
As always, my pleasure!
out of interest do you have any suggestions to to link my counter i to the order:1 4 7 10 2 5 8 11 3 6 9 12?
I am not quite certain what you want to do.
To create a row vector with those values --
v = reshape(reshape(1:12, 3, []).', 1, [])
v = 1×12
1 4 7 10 2 5 8 11 3 6 9 12
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
and a column vector --
v = reshape(reshape(1:12, 3, []).', [], 1)
v = 12×1
1 4 7 10 2 5 8 11 3 6 9 12
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The counter would then index into it as:
for k = 1:numel(v)
fprintf('Index %2d = v(%2d)\n', k, v(k))
end
Index 1 = v( 1) Index 2 = v( 4) Index 3 = v( 7) Index 4 = v(10) Index 5 = v( 2) Index 6 = v( 5) Index 7 = v( 8) Index 8 = v(11) Index 9 = v( 3) Index 10 = v( 6) Index 11 = v( 9) Index 12 = v(12)
If you want something else, please describe it in a bit more detail.
.
Thats perfect, thankyou once again!
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2024b

Etiquetas

Preguntada:

el 5 de Jun. de 2025

Comentada:

el 5 de Jun. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by