MATLAB: Error in storing values

matri

I have a code
for xx = 1:length(dirlist(1:2))
x = imread([pathname, dirlist(xx).name]);
x=rgb2gray(x);
x=double(x);
n = numel(x);
A1_20 = repmat(A,[1,1,20]);
t = ones(size(A));
for j1 = 1:size(A1_20,3)
p = t;
p(randi(n,3000,1)) = 0;
A1_20(:,:,j1) = A1_20(:,:,j1).*p;
w{j}{s1}{s2} =A1_20(:,:,j1);
y1 = idualtree2D(w, J, Fsf, sf);
Er= mean2((single(x) - single(y1)).^2);
final_col2{xx}=min(Er)
% figure,imshow(uint8(y1))
Er1= mean2((single(x) - single(y1)).^2)/20;
Mse{j1}=Er1
end
end
end
end
end
i have taken two images,Mse{j1} stores error for only second image,i want even for 1st image to be stored,the second image error values is overwriting the first ,please help how to store both

Best Answer

I haven't looked in detail, but it looks like the variable xx counts over your images? So, if you replace this line
Mse{j1}=Er1
with this
Mse{xx,j1}=Er1
do you get everything you want stored in Mse?