フィルターのクリア

How can I extract the results of my matlab script to a txt file?

1 回表示 (過去 30 日間)
J. Nash
J. Nash 2017 年 1 月 24 日
コメント済み: Walter Roberson 2017 年 1 月 24 日
I have written a fairly complicated script that does numerous calculations and I want to verify if they are correct. Is it possible to print the output into a text file so I can read it? Thank you for your help.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 1 月 24 日
Use diary()
Alternately, if you do not need input from the user, you could potentially start MATLAB from the command line with a "-r" option to tell it the command to execute; when you do that, you can meaningfully redirect the standard output of the executable using ">", such as
matlab.exe -r "RunMyScript" > TheOutputFile.txt
  2 件のコメント
J. Nash
J. Nash 2017 年 1 月 24 日
One more question. Say I was not satisfied with the output and wanted also the detailed calculations would I be able to print those too? Thank you for answering my question so fast.
Walter Roberson
Walter Roberson 2017 年 1 月 24 日
diary() records everything that was displayed by default, or disp(), or fprintf() with no fid or fprintf() with fid 1 or 2 (if I remember correctly.) So if you wanted more output, you would have to alter the script to display it.
If the intent was something like that you would program to display a summary but in the log you wanted both the summary and details, then in order to do that you would have to fopen() the log and fprintf() to it as well as displaying whatever to the command window. There is no way to say "display this to the diary file only"

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

カテゴリ

Help Center および File ExchangeFiles and Folders についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by