structure to xls file

Hi I want to convert structure to xls file. I have a structure like:
my_stat=struct('Models',{{'KS','FK'}},'Mean',{[mean(KS),mean(FK)]})
I want to write this structure in an excel file. I come up with this one:
fid = fopen('my_results.xls','W');
fprintf(fid, '%f\n', my_stat);
fclose(fid);
type my_results.xls
But my program gives me error message
??? Error using ==> sprintf
Function is not defined for 'struct' inputs.
How shall I proceed?

 Respuesta aceptada

Jan
Jan el 21 de Nov. de 2011

0 votos

fid = fopen('my_results.xls', 'w');
fprintf(fid, '%s\t', my_stat.Models{:});
fprintf(fid, '\n');
fprintf(fid, '%f\t%f\t', my_stat.Mean);
fprintf(fid, '\n');
fclose(fid);
type my_results.xls
if mean(KS) and mean(FK) are not scalars, the format string must be adjusted.

2 comentarios

Meh
Meh el 21 de Nov. de 2011
Perfect!!!!!!!!!! Thanks Jan!!! Only the excel file does not open afterwards. even if i try it manualy!
Meh
Meh el 21 de Nov. de 2011
Problem Solved!. I forgot to delete previous excel file and run again. Now fine.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

Meh
el 21 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by