f = @(d,i)reshape(1:prod(d),flip(d))(num2cell(flip(i)){:}) f([10, 10, 4, 62, 7], [2, 3, 4, 5, 6])
Standard input is empty
f = @(d, i) reshape (1:prod (d), flip (d)) (num2cell (flip (i)) {:}) ans = 22168
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!