Write a substring in a Text file with existing string
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Saeed Soltani
am 30 Mai 2016
Bearbeitet: Saeed Soltani
am 2 Jun. 2016
Hi, I would like to write a word in the following of an existing string in text file, but with my code it deletes the whole and write the new word.
fid = fopen('File.text','w');
fprintf(fid,'%s', NewWord);
I just need to find end of line, and add the new word with only one space to the rest. Should I use textscan or?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 30 Mai 2016
Bearbeitet: Stephen23
am 30 Mai 2016
fid = fopen('File.text','at');
7 Kommentare
Stephen23
am 31 Mai 2016
MATLAB reads fucntion files once and then stores them in memory. This makes them faster (and I guess some JIT optimization occur too). What you are trying to do is to dynamically change MATLAB code, which is not a recommended way of using MATLAB, because it is slow and buggy.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files 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!