How to save all data from a loop in excel?

I calculate statistical values like Entropy, Energy, Mean etc from a 3D image..So I use a loop to go through all slices of the image and calculate the values..How can I save the values of all the slices in excel in different columns each time?

 채택된 답변

MHN
MHN 2016년 3월 28일

0 개 추천

Instead of writing each column in an excel file (which takes a lot of time, since each time you should get access to memory) it is better to save your result in a variable (it might be easier to use a table structure) and save that variable in an excel file finally. then you can easily write that variable in an excel file:
xlswrite('test.xlsx', variable)

댓글 수: 3

Ann G
Ann G 2016년 3월 30일
would you like to give me an example?
Ann G
Ann G 2016년 3월 30일
편집: Ann G 2016년 3월 30일
To be more specific: I calculate the mean and the skewness for 4 slices..
flag=0;
for i=1:4
flag=flag+1;
Mean(flag)=mean(I);
Skewness(flag)=skewness(I);
end
MHN
MHN 2016년 3월 30일
편집: MHN 2016년 3월 30일
T = table(Mean, Skewness);
writetable(T,'myData.xls') % it will be saved in ur current directory

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

질문:

2016년 3월 28일

편집:

MHN
2016년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by