Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to write this cell to a csvfile?

2 visualizaciones (últimos 30 días)
DEVANAND
DEVANAND el 4 de Abr. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi all, If I have a cell with contents like
{'X','Y';
1,'a';
2,'c';
3,'c'}
Now I want to convert this cell to a csvfile like below:
X,Y
1,a
2,c
3,c
How to do this using csvwrite.

Respuestas (1)

DEVANAND
DEVANAND el 4 de Abr. de 2014
OK I did it. This is how I did:
fid = fopen('junk.csv','w');
fprintf(fid,'%s,%s\n',xx{1,:}); % cell name xx with 4*2 elements
for i = 2:4
fprintf(fid,'%d,%s\n',xx{i,:});
end
fclose(fid);
  2 comentarios
Jan
Jan el 4 de Abr. de 2014
Alternative without a loop:
xxt = xx(2:4, :)';
fprintf(fid,'%d,%s\n',xxt{:});
DEVANAND
DEVANAND el 4 de Abr. de 2014
This is a better solution. Thank you.

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by