'Preallocation using MATLAB for Image Registration Technique

I am trying to use image registration. It works; however, it takes a long time to load after I run the code a few more times. I have seen the error in the third image several times and have been trying to figure out how to preallocate the for loop in my code.

From the preallocation documentation, how would I use zeros() for my code below?

for i= 1:n
    [x0,y0] = ginput(1);                                    % Get input from manual selection of points
    hold on
    scatter(x0,y0,'filled')                                 % Show the selected point in the image
    x(i) = x0;
    y(i) = y0;
    [x10,y10] = ginput(1);
    hold on
    scatter(x10,y10,'filled')
    x1(i) = x10;
    y1(i) = y10;
end
x = x-b(2)/2;
y = y-b(1)/2;

enter image description here enter image description here enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source