What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?
Afficher commentaires plus anciens
What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?
Réponse acceptée
Plus de réponses (2)
Azzi Abdelmalek
le 9 Fév 2014
x=[1 2]
fid=fopen('filename.txt','w')
fprintf(fid,'%10.1f',x)
fclose(fid)
1 commentaire
Tucker Russ
le 10 Fév 2014
Image Analyst
le 9 Fév 2014
Modifié(e) : Image Analyst
le 10 Fév 2014
In regards to your question "What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?"
fprintf(F_ID, '%f, %f\n', number1, number2);
That will put them on their own line, separated by a comma. If you want a certain number of decimal places, say 3, then do it like this:
fprintf(F_ID, '%.3f, %.3f\n', number1, number2);
1 commentaire
Tucker Russ
le 10 Fév 2014
Catégories
En savoir plus sur Standard File Formats dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!