timestamp in command window

조회 수: 26 (최근 30일)
Max Bernstein
Max Bernstein 2011년 11월 5일
Hello,
Is there anyway I can enable timestamp for the command window all the time by default? not just when running a script. I would like it to display for both input and output, something like this:
[05.11.2011 15:38:23] >> 1+1
[05.11.2011 15:38:24] ans = 2
Thanks

답변 (2개)

the cyclist
the cyclist 2011년 11월 5일
That functionality is not native to MATLAB, but the following File Exchange function will do what you want:

Walter Roberson
Walter Roberson 2011년 11월 5일
Alas, the cyclist's answer will not timestamp each line of output, but it does nicely solve timestamping each >> prompt.
To timestamp each line of output, you would have to override the routines disp() and display() and fprintf() at the very least. Or, depending exactly how disp() and display() are implemented, perhaps only fprintf() .
I would hesitate strongly to override fprintf(): I think there is just too much potential for disaster in doing that.
In the situation where only the command line version of MATLAB was required, no graphics were required, and the desktop environment was not required, then there would be approaches to this that would be more secure, involving the use of pseudo-terminals (pttys). pseudo-terminals are fairly easy to set up in unix-like systems, and are theoretically available in MS Windows, but I have never used them myself in MS Windows.
On the other hand, MATLAB is not known for playing well with pseudo-terminals, in the sense that MATLAB for some reason overrides the standard line-buffering detection built in to unix and MS Windows and deliberately uses block-oriented buffering.

카테고리

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