フィルターのクリア

fprrintf MATLAB R2013a not working

1 回表示 (過去 30 日間)
Yasmin Tamimi
Yasmin Tamimi 2014 年 9 月 29 日
コメント済み: Stephen23 2014 年 9 月 29 日
Hey everyone,
I'm sending my values to a txt file in MATLAB R2013a but the txt file remains empty and all the printing is done in the command window! Does anyone know why is this happening? And how can I print the values in a txt file?
fid = fopen('Code.txt','w');
fprintf('start a new cycle \n');
fprintf('t = %0.5f\t total_diss %0.5f\n', t, total_diss)
fclose(fid);
  1 件のコメント
Stephen23
Stephen23 2014 年 9 月 29 日
For those reading this question, this is covered in the fprintf documentation:
Syntax
fprintf(fileID,formatSpec,A1,...,An)
...
Input Arguments
fileID — File identifier1 (default) | 2 | scalar
File identifier, specified as one of the following:
  • A file identifier obtained from fopen.
  • 1 for standard output (the screen).
  • 2 for standard error.

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

採用された回答

Mischa Kim
Mischa Kim 2014 年 9 月 29 日
編集済み: Mischa Kim 2014 年 9 月 29 日
Yasmine, use
fid = fopen('Code.txt','w');
fprintf(fid,'start a new cycle \n');
fprintf(fid,'t = %0.5f\t total_diss %0.5f\n', t, total_diss)
fclose(fid);
instead. Note that you need to add the fileID fid to the fprintf command.

その他の回答 (0 件)

カテゴリ

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