MATLAB: How can i simultaneously reference in cells

cellcell arrays

I have a cell array, lets say C. Each cell contains a matrix.
For example lets say C is
C{1}=[1 2;3 4;5 6]
C{2}=[7 8;9 10;11 12]
How can I create a new cell array D, whose i-th element is a matrix consisted by the i-th transposed rows of all matrices in C?
Then D must be
D{1}=[1 7;2 8]
D{2}=[3 9;4 10]
D{3}=[5 11;6 12]

Best Answer

This is fun... you can try
C{1}=[1 2;3 4;5 6]
C{2}=[7 8;9 10;11 12]
g = @(j)[C{1}(j,:);C{2}(j,:)]'; % function handle
D = arrayfun(g,1:3,'UniformOutput',false); % awesome function