zero padding a matrix

后端 未结 5 701
深忆病人
深忆病人 2021-01-13 19:18

I have a 16X16 matrix. I have to add it to a 256X256 matrix. Can anyone help me how to make this 16X16 matrix into 256X256 filling the remaining with zeros?

5条回答
  •  春和景丽
    2021-01-13 19:47

    Matlab automatically pads with zeros if you assign something to an element outside of the original size.

    >> A = rand(16, 16);
    >> A(256, 256) = 0;
    >> size(A)
    ans =
       256   256
    

提交回复
热议问题