Diary command does not capture command window results from a script file.
조회 수: 20 (최근 30일)
이전 댓글 표시
I'm looking to use the diary feature to save the command window results obtained after running a script file. The diary file is empty after initiating the diary {filename} command and then executing the m-file script. My expectation is that everything seen and displayed in the command window is captured in the diary file. I am curently using the MATLAB online resource to run my m-file scripts.
Is capturing command window results generated from a m-file script not possible with the diary command?
댓글 수: 3
Rik
2022년 10월 20일
Can you attach the script? That way we can have a look wether anything in the script could possibly interfere.
답변 (2개)
Rik
2022년 10월 20일
Even setting a full path for the diary file didn't work.
DiaryFileName = fullfile(tempdir,'myFile.txt');
diary(DiaryFileName)
The only way I can think of to capture this is with evalc (which you should never use otherwise):
DiaryContent = evalc('Class_Week7A');
fid = fopen( DiaryFileName ,'w');
fprintf(fid,'%s',DiaryContent);
fclose(fid);
type(DiaryFileName)
You should never use eval (or evalc). In this case the better way would be to incorporate an actual logging system, where you replace disp with fprintf.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!