I have to use in C this function:

stack=cat(3,rpad{i,:});

Cat utilization:
Concatenate arrays along specified dimension(3rd)