How can I input all the results using xlswrite for each loop?

2 ビュー (過去 30 日間)
Braiki Marwa
Braiki Marwa 2017 年 8 月 8 日
編集済み: Braiki Marwa 2017 年 8 月 10 日
When I run the following code:
for i=1:3
for niter=1:2
img_filtree=smooth_diffusion(I,edgestop(i),'dir',5,niter,0.25);
% figure(1),imshow(img_filtree);
% saveas(figure(1), strcat('Résultats\','img_filtree',num2str(niter),'_edgestop',num2str(i),'.tif'));
imwrite(img_filtree,strcat('Résultats\','img_filtree_',num2str(niter),'-edgestop',num2str(i),'.tif'));%
peaksnr{i,niter}=psnr(img_filtree,Isynth)
snr{i,niter}=psnr(img_filtree,Isynth)
% [peaksnr,snr] = psnr(img_filtree,Isynth)
Ed=edge(img_filtree);
% F= pratt(Ea,Ed);
F{i,niter}= pratt(Ea,Ed)
filename = 'testdata.xlsx';
A = {'PSNR','SNR','FOM'; peaksnr{i,niter}, snr{i,niter},F{i,niter}};
% sheet = 2;
xlRange = 'A1';
% xlswrite(filename,A,sheet,xlRange)
xlswrite(filename,A,xlRange)
end
end
I got just the final result
  2 件のコメント
Bastien Dietemann
Bastien Dietemann 2017 年 8 月 8 日
I hope to get your question right. You want to save your results in an excel sheet and you are concerned that your results get overwritten each time, correct? If this is the case and you do not care about the layout, you could simply predefine the cells in which you results are saved in. Put
mycells = {'A1','E1','I1';'A4','E4','I4'};
before the loops and then instead of xlRange = 'A1' you write
xlRange=mycells{niter,i};
Does this solve your problem?
Braiki Marwa
Braiki Marwa 2017 年 8 月 8 日
編集済み: Braiki Marwa 2017 年 8 月 8 日
Thanks Bastien Dietemann for your reply but this solotion can't solve the problem
mycells = {'A1','E1','I1';'A4','E4','I4'};
for i=1:3
for niter=1:2
img_filtree=smooth_diffusion(I,edgestop(i),'dir',5,niter,0.25);
% figure(1),imshow(img_filtree);
% saveas(figure(1), strcat('Résultats\','img_filtree',num2str(niter),'_edgestop',num2str(i),'.tif'));
imwrite(img_filtree,strcat('Résultats\','img_filtree_',num2str(niter),'-edgestop',num2str(i),'.tif'));% [peaksnr1,snr1] = psnr(img_filtree1,Isynth)
peaksnr{i,niter}=psnr(img_filtree,Isynth)
snr{i,niter}=psnr(img_filtree,Isynth)
Ed=edge(img_filtree);
F{i,niter}= pratt(Ea,Ed)
filename = 'testdata.xlsx';
A = {'PSNR','SNR','FOM'; peaksnr, snr,F};
% sheet = 2;
xlRange=mycells{niter,i};
% xlRange = 'A1';
% xlswrite(filename,A,sheet,xlRange)
xlswrite(filename,A,xlRange)
end
end
I want a table like this:

サインインしてコメントする。

回答 (1 件)

Bastien Dietemann
Bastien Dietemann 2017 年 8 月 9 日
編集済み: Bastien Dietemann 2017 年 8 月 9 日
Okay, let's have another try. I don't have your functions so I cannot test your Version, but this should work.
filename = 'testdata.xlsx';
xlswrite(filename,{'iteration'},1,'A2');
xlswrite(filename,{'edgestop1'},1,'C1');
xlswrite(filename,{'edgestop2'},1,'F1');
xlswrite(filename,{'edgestop3'},1,'I2');
xlswrite(filename,{'PSNR' 'SNR' 'FOM'},'B2:D2');
xlswrite(filename,{'PSNR' 'SNR' 'FOM'},'E2:G2');
xlswrite(filename,{'PSNR' 'SNR' 'FOM'},'H2:J2');
max_niter = 2;
%create destinations
mycells=cell(max_niter,3);
for i =1:max_niter
mycells{i,1}=sprintf('B%i:D%i',i+2,i+2);
mycells{i,2}=sprintf('E%i:G%i',i+2,i+2);
mycells{i,3}=sprintf('H%i:J%i',i+2,i+2);
end
for i=1:3
for niter=1:max_niter
img_filtree=smooth_diffusion(I,edgestop(i),'dir',5,niter,0.25);
% figure(1),imshow(img_filtree);
% saveas(figure(1), strcat('Résultats\','img_filtree',num2str(niter),'_edgestop',num2str(i),'.tif'));
imwrite(img_filtree,strcat('Résultats\','img_filtree_',num2str(niter),'-edgestop',num2str(i),'.tif'));% [peaksnr1,snr1] = psnr(img_filtree1,Isynth)
peaksnr{i,niter}=psnr(img_filtree,Isynth);
snr{i,niter}=psnr(img_filtree,Isynth);
Ed=edge(img_filtree);
F{i,niter}= pratt(Ea,Ed);
A = {peaksnr, snr,F{i,niter}};
xlRange=mycells{niter,i};
xlswrite(filename,A,xlRange)
end
end
  2 件のコメント
José-Luis
José-Luis 2017 年 8 月 9 日
If performance is an issue (and it will be if you call xlswrite repeatedly), it might be better to use ActiveX controls.
Braiki Marwa
Braiki Marwa 2017 年 8 月 10 日
編集済み: Braiki Marwa 2017 年 8 月 10 日
Dear Bastien Dietemann, I try your solution, it gives me this result :
I change A = {peaksnr, snr,F{i,niter}}; by A = {peaksnr{i,niter}, snr{i,niter},F{i,niter}}; it gives me this result :
But there are still two problems with this code:
1) edgestop3
2) The number of iteration

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by