about dlmwrite
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Fangjun Jiang
il 20 Lug 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 Commenti
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!