But, i've tried another solution an work for me as well.
indir = uigetdir(cd, 'Select input folder');
directory = dir([indir, '\', '*.jpg']);
for i = 1 : length(directory)
filename = directory(i).name;
ref = imread([indir, '\', filename]);
A = imnoise(ref, 'salt & pepper', 0.02);
[peaksnr, snr] = psnr(A, ref);
fprintf('\n Peak-SNR Original : %0.4f',peaksnr);
fprintf('\n SNR Original : %0.4f \n',snr);
writematrix(peaksnr,'psnrO.csv','WriteMode','append');
writematrix(snr,'snrO.csv','WriteMode','append');
end
just add the writemode and append argument, then the values will save all in one csv.