Hi, anybody can help me from this code, I want to save all peaksnr output into one .csv using writematrix, but this code only save one value into the .csv. Is there any method i can use to make sure all the output save into one csv. %% Here is my code indir = uigerdir(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, sprintf('psnrO.csv',i+1)) end Thank you for your help.
Kshitij Singh answered .
2025-11-20
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.