fork download
  1. f = @(d,i)reshape(1:prod(d),flip(d))(num2cell(flip(i)){:})
  2.  
  3. f([10, 10, 4, 62, 7], [2, 3, 4, 5, 6])
  4.  
  5.  
Success #stdin #stdout 0.73s 121792KB
stdin
Standard input is empty
stdout
f =

@(d, i) reshape (1:prod (d), flip (d)) (num2cell (flip (i)) {:})

ans =  22168