Efficient way to divide array into tiles
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!