Hi, man. Thanks very much for your help. I know that this operation may looks very strange. But, I have  to do it. Instead of padding, this is actually to encode the original vector a=[2,3,4].  As I think my current codes are too “ugly”, I’m seeking for some more elegant ways to get it done.