Convert string to txt
41 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a 4x1 string array, how can i write it and save it as a txt file? Not sure if i did it correctly.
A=(4x1) string array
fid = fopen('A.txt','wt');
fprintf(fid, '%s\n',A);
fclose(fid);
5 comentarios
Ameer Hamza
el 2 de Abr. de 2020
Editada: Ameer Hamza
el 5 de Abr. de 2020
You should not run save('A.txt'). It is useless for your problem.
Respuestas (1)
Maadhav Akula
el 5 de Abr. de 2020
Hi,
I think you are getting that extra line because of the '\n' escape character. You can try the following code :
fid = fopen('A.txt','w');
fprintf(fid, '%s\n',A(1:end-1));
fprintf(fid,'%s',A(end));
fclose(fid);
Hope this Helps!
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion 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!