Function diary does not change line in the text file

I write the following code,
diary Log.txt
disp('Hello!');
disp('World!');
diary off
The command window displays as follows,
Hello!
World!
It is correct.
But when I open the text file Log.txt using Notepad, the saved history shows as follows,
Hello!World!
It is wrong! The saved history in the text file does not change lines as the command window does.
But when I open the text file Log.txt on another computer also using Notepad, the saved history shows as follows,
Hello!
World!
It is correct.
Could anyone tell me what the problem is?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 11월 18일

0 개 추천

I suspect that you are opening the file using Notepad, which does not know about Linefeed alone as a delimiter. You should use a more modern editor.

댓글 수: 3

Ryan
Ryan 2020년 11월 18일
Yes, I open the file using Notepad.
But when I open the text file Log.txt on another computer also using Notepad, the saved history shown is correct.
It is very confusing.
Rik
Rik 2020년 11월 18일
You should probably consider the suggestion from Walter. I personally prefer Notepad++, as that has many features, while still being a fast basic file reader.
Another option, since you're using MATLAB, is to open the text file in the MATLAB Editor.

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

카테고리

도움말 센터File Exchange에서 Language Support에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

2020년 11월 18일

댓글:

2020년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by