필터 지우기
필터 지우기

about dlmwrite

조회 수: 3 (최근 30일)
Cenk OZAN
Cenk OZAN 2011년 7월 20일
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?

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 7월 20일
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.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by