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?
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
padded = zeros(256,256);
data = rand(16,16);
padded(1:16,1:16) = data;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With