To fill an array, you can use PADARRAY if you have an image processing toolbar.
Otherwise, you can skip and compress the following path:
smallArray = rand(10); %# make up some random data border = [2 3]; %# add 2 rows, 3 cols on either side smallSize = size(smallArray); %# create big array and fill in small one bigArray = zeros(smallSize + 2*border); bigArray(border(1)+1:end-border(1),border(2)+1:end-border(2)) = smallArray; %# perform calculation here %# crop the array newSmallArray = bigArray(border(1)+1:end-border(1),border(2)+1:end-border(2));
source share