I think this does it for the first of your desired d's:
d = reshape(permute(reshape(a,3,3,2,2),[1,3,2,4]),6,6);
Added:
The second desired d should be obtained with:
d = reshape(permute(reshape(a,3,3,2,2),[1,4,2,3]),6,6);
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!