How can I programatically print out the contents of the MATLAB Command Window?
9 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2016-9-27
回答: MathWorks Support Team
2016-9-27
The contents of MATLAB's Command Window can be printed out by using 'Ctrl + P' or right-clicking and selecting "Print..." from the Command Window itself. How can I do the same programmatically, such as from within scripts?
采纳的回答
MathWorks Support Team
2016-9-27
This functionality can be emulated by using the "diary" and "system" commands. First, use "diary" to enable Command Window logging and save it in a file:
>> diary('commandLog')
>> diary on
This creates a file named 'commandLog' in MATLAB's current folder. Now, execute the commands of interest. Be sure to not suppress the output of variables with semicolons if you would like them to be written to the file. Once you are ready to print the file, execute the following commands to turn off diary logging, print the text file through Notepad, and then delete the file:
>> diary off
>> system('notepad /p commandLog')
>> delete('commandLog')
It is recommended that the file be deleted every time this workaround is used since "diary" appends Command Window text to the file if it already exists.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!