How to save all data from a loop in excel?

1 visualización (últimos 30 días)
Ann G
Ann G el 28 de Mzo. de 2016
Editada: MHN el 30 de Mzo. de 2016
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?

Respuesta aceptada

MHN
MHN el 28 de Mzo. de 2016
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 comentarios
Ann G
Ann G el 30 de Mzo. de 2016
Editada: Ann G el 30 de Mzo. de 2016
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 el 30 de Mzo. de 2016
Editada: MHN el 30 de Mzo. de 2016
T = table(Mean, Skewness);
writetable(T,'myData.xls') % it will be saved in ur current directory

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by