Command Window Output to txt file

조회 수: 2 (최근 30일)
Pedro Felipe Oliveira
Pedro Felipe Oliveira 2015년 9월 6일
답변: ibenitoseb 2019년 3월 28일
How can I save the output data generated in command window in *.txt file? I tried to use the diary function, but I want one file for each program execution. Thanks in advance.

채택된 답변

Mohammad Abouali
Mohammad Abouali 2015년 9월 6일
You could instruct your code to force the diary into a separate file each time your code is executed. Something like this:
diary(sprintf('run_%s_%d.txt',datestr(now,'yyyy_mm_dd_HH_MM_SS'),randi([1,10000],1)))
depending on the time you are running your code a separate file is generated for example:
run_2015_09_06_16_27_47_8148.txt
the output would be stored in a file such as above. That changes everytime you run that code snippet.
  댓글 수: 1
Pedro Felipe Oliveira
Pedro Felipe Oliveira 2015년 9월 8일
It Works Sir Abouali. Thanks a lot!!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

ibenitoseb
ibenitoseb 2019년 3월 28일
This tutorial shows you how: https://www.youtube.com/watch?v=KF3xCpKhb_s&t=62s

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by