How to concatenate smaller matrices to form a larger matrix?
<p>I would like to concatenate 14641 number of 3X3 matrices into a matrix of size 363X363 and the large matrix must contain 121 submatrices in each row(121*3=363 columns) and 121 such rows of submatrices(121*3=363rows).I have gone through the similar questions but I didn't get the correct logic to concatenate large number of matrices.
Awaiting your suggestions. Thanks in advance.</p>

<p>PS: I got those 3X3 matrices from a 363X363 matrix. The following code is for splitting the single matrix into submatrices.</p>

<pre><code>I=imread('photo.jpg');
B = randi([0 255],363,726,3);
B(1:numel(I)) = I;
L=B(1:363,1:363);
[al,bl]=size(L);
ImageSize=al*bl;
BlockD=3; % i assume 3x3 block
BlockSize=BlockD*BlockD;
TotalBlocks=ImageSize/BlockSize;
subL=zeros(BlockD,BlockD,TotalBlocks); %arrays of blocks.
LL=double(L); 
k=1;
for i=1:BlockD:al
 for j=1:BlockD:bl
    subL(:,:,k)=LL(i:i+BlockD-1,j:j+BlockD-1); 
    k=k+1;
 end
end
</code></pre>

<p>Now I want to concatenate all these 'subL' submatrices to form 'LL' again </p>

<h2>Using blocproc instead of above code</h2>

<p>I tried using blockproc function instead of the above code. I did this piece of code and is working pretty well.Thank you</p>

<pre><code>I=imread('photo.jpg');
B = randi([0 255],363,726,3);
B(1:numel(I)) = I;
L=B(1:363,1:363);
q=[1 2 3 4];
fun=@(block_struct)quaternionrotate(q,block_struct.data);
LL = blockproc(L,[3 3],fun);
</code></pre>

<p>and the function quaternionrotate is</p>

<pre><code>function [ Lrot1 ] = quaternionrotate(q,A)
 qinv=quatinv(q);
 B=zeros(3,1);
 A1=[B A];
 Lrot=quatmultiply(q,quatmultiply(A1,qinv));
 Lrot(:,1)=[];
 Lrot1=Lrot;
end
</code></pre>