fork download
  1. @(M)accumarray(((1:size(M,1))+(0:size(M,2)-1)')(:),M(:),[],@(x){num2str(x')})
  2.  
  3. ans([1 2 3; 4 5 6; 7 8 9])
Success #stdin #stdout 0.56s 121984KB
stdin
Standard input is empty
stdout
ans =

@(M) accumarray ((1:size (M, 1) + 0:size (M, 2) - 1') (:), M (:), [], @(x) {num2str(x')})

ans = 
{
  [1,1] = 1
  [2,1] = 4  2
  [3,1] = 7  5  3
  [4,1] = 8  6
  [5,1] = 9
}