export data to txt file

17 vues (au cours des 30 derniers jours)
masoud meskin
masoud meskin le 7 Nov 2016
Modifié(e) : Jan le 7 Nov 2016
Hi guys when i export my daa to a txt file, it exports the numbers with 4 digits after zero like 0.1256. How can i export my data with higher accuracy let's say with 5 or 6 digits after zero like 0.125647?tnx
filename=strcat('transient_profile_fromfrp_450_',num2str(Q),'litmin.txt'); fileID1 = fopen(filename,'w'); formatSpec = 'annalisadiscovered 2 600 0\n'; fprintf(fileID1,formatSpec); fprintf(fileID1,'%5s %6s\n','time',' velocity'); fprintf(fileID1,'%1.4f % 1.4f\n',velo_t1); fclose(fileID1);

Réponse acceptée

Jan
Jan le 7 Nov 2016
Modifié(e) : Jan le 7 Nov 2016
Change:
fprintf(fileID1,'%1.4f % 1.4f\n',velo_t1)
to
fprintf(fileID1,'%1.6f % 1.6f\n',velo_t1)
This is explained exhaustively in the documentation of the fprintf command, so please read
doc fprintf

Plus de réponses (0)

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by