Write a .txt file
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have information like:
Coisas
X 3.16
Y 1.53
Z 0.000000Lat 0.000000Long
Cenas
X 275.30
Y 0.00
Z 142.43
K 0.000000 0.000000
T 43.734380 7.421440
How can I write this in a file.txt to apear like I have hear. I have already all the fprintf. But when I put to fid it stay different.
And this file need to be rewrite again, i will add info like that.
It´s like I open the file and write this and i close. then I want to open again e write more info. How can I do that. It dissapear all the previous info.
Thanks
0 commentaires
Réponse acceptée
Walter Roberson
le 7 Déc 2013
When you first create the file,
fid = fopen('Yourfile.txt', 'wt');
Each time you want to add something to it after having already closed it,
fid = fopen('Yourfile.txt', 'at');
5 commentaires
Walter Roberson
le 8 Déc 2013
Yes, you use \n in files. But when you write something to a file and then close it, there is no \n automatically added: opening for append and writing something else would continue the exact same line.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings 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!