フィルターのクリア

problem with using fprintf

1 回表示 (過去 30 日間)
Maryam Hamrahi
Maryam Hamrahi 2016 年 6 月 13 日
コメント済み: Walter Roberson 2016 年 6 月 13 日
I would like to use fprintf to save the following line as a text file.
%%number of points: x
x is a variable and for instance x=25
%%number of points: 25
thank you very much
  2 件のコメント
Adam
Adam 2016 年 6 月 13 日
And what aspect of it is causing you a problem?
Maryam Hamrahi
Maryam Hamrahi 2016 年 6 月 13 日
I do not know how to write it

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 13 日
fid=fopen('your_file.txt','w')
x=25
str=sprintf('number of points: %d',x)
fprintf(fid,'%s',str)
fclose(fid)
  4 件のコメント
Maryam Hamrahi
Maryam Hamrahi 2016 年 6 月 13 日
thanks a lot
Walter Roberson
Walter Roberson 2016 年 6 月 13 日
I would just go for
fid = fopen('your_file.txt', 'w');
x = 25;
fprintf(fid, '%%%%number of points: %d\n', x);
fclose(fid);

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by