Insert 2 cell arrays in txt data
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
cemsi888
el 20 de Mzo. de 2017
Comentada: Renato Agurto
el 21 de Mzo. de 2017
Hi I have a really easy question. I have one cell Array which consists of 2 cells. I would like to write These two cells in txt data. Actually i can now write both cells in txt however i would like put tab between both two cell elements. Although I added \t. Matlab does not put tab both elements. Could u please help me.Here is my code.
formatSpec='%s\t\n'
for ii=1:length(combined_data(:,1))
com1=char(combined_data{ii,1}{1,1});
com2=char(combined_data{ii,2}{1,1});
fprintf(fid ,formatSpec, [com1,com2]);
thanx a lot
end
fclose(fid);;
0 comentarios
Respuesta aceptada
Renato Agurto
el 20 de Mzo. de 2017
I think you need two %s separated by the tab:
formatSpec='%s\t%s\n'
and:
fprintf(fid ,formatSpec, com1, com2); %without brackets
2 comentarios
Renato Agurto
el 21 de Mzo. de 2017
with brackets you join the 2 chars into one char. Without brackets you assign every char (com1 & com2) to the respective '%s' in your string.
I hope this helps you
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!