update the text file

조회 수: 2 (최근 30일)
raviranjan singh
raviranjan singh 2018년 5월 30일
댓글: Walter Roberson 2018년 5월 30일
i have only call the number from text file in edit text and if the number is change, it must be update at the give place in same text. there is any code to update the change value in same text after clicking the push bottom for given edit text box.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 5월 30일
Updating text files is not recommended. It is only possible if the replacement is exactly the same size as the original text.
It is recommended that instead you write a new text file with the new content, and that you do not get rid of the old file until you are certain that the new one is correct.
  댓글 수: 2
raviranjan singh
raviranjan singh 2018년 5월 30일
in my text file both number and sentence is there and i changes only number, than what i can do?
Walter Roberson
Walter Roberson 2018년 5월 30일
You can read from the old file, copying to a new file, except for the values you want changed, where you would write out the new value instead.
There is no possibility to just update part of a text file, except in the case where the new text is exactly the same size as the old text. This is not a MATLAB limitation: it is a fundamental restriction on all programs due to the way that text files are stored.
(Historically, there were a couple of operating systems that permitted text files to be stored in a way that permitted them to be updated, but the simplicity and efficiency of the current way of storing files won out in the early 80s.)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by