矩阵末尾的Matlab零填充

Matlab zero padding at the end of a matrix

我在 matlab 中得到了一个大小为 A 0 100x100 的数组,我想用 3 行 4 列零来填充它,所以下一个大小是 103x104 。这在 matlab 中如何实现?

我试过了

         A=padarray(A,[3,4]);

它不起作用。提前致谢。

A=padarray(A,[2,2]);

这将在矩阵的顶部、底部、左侧和右侧添加填充。新维度将为 104x104。填充只能对称地完成。在 [2,2]

First 2 represents 2 rows in top and 2 rows in bottom of matrix (row size 2+100+2)

Second 2 represents 2 columns in left and 2 columns in right of matrix (column size 2+100+2)

如果你只想在右边和底部做填充。然后使用下面的代码。

rowPad=3;
colPad=4;
A=padarray(A,[rowPad,colPad]);
A(1:rowPad,:)=[];
A(:,1:colPad)=[];

新维度将为 103x104