timestamp in command window

23 ビュー (過去 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 Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by