How can I programatically print out the contents of the MATLAB Command Window?
조회 수: 6 (최근 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!