How do i store all the results from a set of 'for' loops, not just the results from the last iteration?
1 view (last 30 days)
When i run my script each time my for loop runs it overwrites the results of the previous itteration, is there a way to have it store all the results from each iteration? Here is the code in question.
img = imread('cameraman.tif');
for Mean = 0.01:0.01:0.1
noise = imnoise(img,'gaussian',Mean,V);
NoisePower = V*numel(img);
NPowerInt = fix(NoisePower);
[peaksnr, snr] = psnr(noise,img);
nsr = 1/snr;
for hsize = 3:1:26
for sigma = 0.5:0.5:5
PSF = fspecial('gaussian',hsize,sigma);
NoiseyBlurred = imfilter(noise,PSF,'replicate','same','conv');
BlindDeconv = deconvblind(NoiseyBlurred,PSF,15);
LucyFilter = deconvlucy(NoiseyBlurred,PSF,15);
WNRFilter = deconvwnr(NoiseyBlurred,PSF,nsr);
RegularFilter = deconvreg(NoiseyBlurred,PSF,snr);
PSNRBlurred = psnr(NoiseyBlurred,img);
PSNRBlind = psnr(BlindDeconv,img);
PSNRLucy = psnr(LucyFilter,img);
PSNRWNR = psnr(WNRFilter,img);
PSNRReg = psnr(RegularFilter,img);
I can't store the data based off 'Mean' instead of hsize as it gives the error Subscript indices must either be real positive integers or logicals. I've tried having the hsize loop first but this just saves the results from the final sigma and Mean values at each hsize value. I have also tried creating a logical from the Mean to store the results but this didn't work either. I'm out of ideas, so any help would be greatly appreciated.
MaryD on 16 Apr 2020
Mean = 0.01:0.01:0.1
hsize = 3:1:26
sigma = 0.5:0.5:5
noise(m) = imnoise(img,'gaussian',Mean(m),V);
%%%rest of the code
Try storing your variable like this.