How do we save command window output to a text file?

71 ビュー (過去 30 日間)
Zayd Islam
Zayd Islam 2021 年 3 月 23 日
コメント済み: navanit dubey 2021 年 3 月 24 日
How do we save command window output to a text file? The professor does not want us to use fprintf function to write data to text file. I want the text file name to be 'DailySummaries'. I have done this currently but it does not save it as a .txt file
diary on
diary('DailySummaries')
disp(strcat('Day',{' '},num2str(data(i).elapsedtime(3)),{' '},' Healthy People = ',{' '},num2str(data(i).healthy)))
disp(strcat('Day',{' '},num2str(data(i).elapsedtime(3)),{' '},' Infected People = ',{' '},num2str(data(i).infected)))
disp(strcat('Day',{' '},num2str(data(i).elapsedtime(3)),{' '},' Sick People = ',{' '},num2str(data(i).sick)))
disp(strcat('Day',{' '},num2str(data(i).elapsedtime(3)),{' '},' Recovered People = ',{' '},num2str(data(i).recovered)))
diary off

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 3 月 23 日
diary does create a text file. However, diary() does not automatically add any file extension, so your File Explorer does not know how to open the file.
diary('DailySummaries.txt')
  2 件のコメント
Zayd Islam
Zayd Islam 2021 年 3 月 23 日
great realised this just now thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by