write values of different programm in next row of a text file
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Bruce Rogers
am 1 Jul. 2021
Kommentiert: Bruce Rogers
am 1 Jul. 2021
Hello everyone,
I got a large programm for different experiments. Now I want to write the new result value in the same text file in the next row. Is this possible and how can I do that? Is there a function for that? I'm using Matlab R2020b for acadeic use.
I'm thankful for your ideas!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670778/image.png)
0 Kommentare
Akzeptierte Antwort
Smitesh Patil
am 1 Jul. 2021
Bearbeitet: Smitesh Patil
am 1 Jul. 2021
Open the file in append mode
fileID = fopen('experiment_data.txt','a');
Then write the data using fprintf (assuming that data is just array of integers)
fprintf(fileID, "%d ", data);
then close the file
fclose(fileID);
Weitere Antworten (1)
KSSV
am 1 Jul. 2021
Tou need to use '\n' in fprintf to write in the next line of the file. Read about fprintf.
fprintf('new line\n')
fprintf('Hello I am here')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!