MATLAB: How to take values from corr2 loop

corr2image processingMATLAB

I want to take all values P and build a grapth. Pxi
But the problem is that matlab gives me only one vatiable the final corrilaton, but i want to take corrilaton for each step from 1 to 30. How could i do this?
thank you a lot for you answer.
Ia = imread ('rooster.jpg');
Ib = imread ('woods (1).png');
Ia = rgb2gray (Ia);
Ia = im2double(Ia);
Ib = im2double(Ib);
for i = 1:30
K = imtranslate (Ia, [i,0])
P = corr2(Ia,K);
end

Best Answer

"...matlab gives me only one vatiable the final corrilaton..."
That's because on each iteration of the loop you're overwriting the previous value of P. Here's how to save all iterations.
P = nan(1, 30); %allocate P
for i = 1:30
K = imtranslate (Ia, [i,0])
P(i) = corr2(Ia,K); %save corr. upon each iteration
end