MATLAB: Matrix padding with zero

Image Processing Toolboxmatrix paddingpadding

I have a 3×3 matrix and a 2×3 matrix. I need to pad zeros in the 2×3 matrix only at the bottom row such that it becomes 3×3.
If i have another matrix let's say 5×4 and second one 5×2, i need to pad the last 2 columns of the 5×2 matrix such that it has same rows and columns as 5×4.
a = [1,2,3; 3,2,1; 1,2,3];
b = [1,2,3; 3,2,1];
d = padarray(b,[1,0],0)
This code is padding a row above and a row below the matrix but i just want it below the 2×3 matrix.

Best Answer

Try this trick:
matrix2x2(3,3) = 0; % Add a row of zeros.
Then to turn the 5x2 into a 5x4:
b = rand(5,2)
array5x4 = padarray(b,[0,2],0, 'post')