Efficient way to divide array into tiles
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yi-xiao Liu
am 31 Okt. 2022
Kommentiert: Yi-xiao Liu
am 2 Nov. 2022
I use the following code to divide array into tiles
n=2;nrow=3;ncol=3;
A=reshape(1:36,6,6)
A=mat2cell(A,zeros(nrow,1)+n,zeros(ncol,1)+n);
A=reshape(A,1,[]);
A=cellfun(@(x) x(:),A,"UniformOutput",false);
A=cell2mat(A)
Now each column contains the element of each 2-by-2 tile.
The problem is when A is large and n is small the use of cell array creates significant overhead. Is there a more efficient way to do this?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!