Search code examples
pythonmatlabpad

how to convert padarray post to python pad function


im having a problem to convert post in matlab padarray to pad function in python, i want to do the same in python pad function :

padded=np.pad(MAT,(1,1),'post');

this is not working because there is no post function in python

this is an example in matlab (i want to do the same in python pad function):

enter image description here

it will really help me , thank you


Solution

  • a=np.array([[1,3,4]])
    b=np.pad(a,((0,1),(0,0)),'constant')
    

    Notice that a should be a two dimensional array. If this is confusing, read the documentation: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.pad.html