about dlmwrite
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a text file which consists of numbers (for example myfile.txt=[1 2 3;4 5 6; 7 8 9]. I want to replace its "5 6 8 9" elements with new matrix (for example A=[3 2;4 1]). Other elements in myfile.text must be same. I tried it with dlmwrite, dlmwrite ('myfile.txt',A,' ',1,2), but other elements was deleted. How can I change only these elements without deleting other elements?
0 Kommentare
Antworten (1)
Fangjun Jiang
am 20 Jul. 2011
DLMWRITE('FILENAME',M,'DLM',R,C) writes matrix M starting at offset row R, and offset column C in the file. But it will completely over-write the existing file anyway. It just leaves some delimiter to make the offset. It's not going to open the old file, find the offset and just over-write the new data.
You'll have to read in the whole data, do the proper replacement in MATLAB and then write it back.
0 Kommentare
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!