@mcabbott, what are the advantages of your proposed solution over OP’s original idea of using: permutedims(stack(a),(2,3,1)) ?
permutedims(stack(a),(2,3,1))
Thanks.
NB: This post answers the question.