timestamp in command window

28 次查看(过去 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 中查找有关 Entering Commands 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by