フィルターのクリア

What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?

1 回表示 (過去 30 日間)
What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?

採用された回答

Wayne King
Wayne King 2014 年 2 月 9 日
編集済み: Wayne King 2014 年 2 月 9 日
fprintf(F_ID, '%1.1f %1.1f\n', X)
where X has two columns. X is the variable in the MATLAB workspace contain the numbers.
Or
fprintf(F_ID, '%1.1f %1.1f\n', a,b)
where a = 1.0 and b = 2.0

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 9 日
x=[1 2]
fid=fopen('filename.txt','w')
fprintf(fid,'%10.1f',x)
fclose(fid)

Image Analyst
Image Analyst 2014 年 2 月 9 日
編集済み: Image Analyst 2014 年 2 月 10 日
In regards to your question "What is the syntax of fprintf? Suppose there are two flot numbers 1 and 2, and F_ID is the file identifier. Write the command to sabe the two numbers to F_ID?"
fprintf(F_ID, '%f, %f\n', number1, number2);
That will put them on their own line, separated by a comma. If you want a certain number of decimal places, say 3, then do it like this:
fprintf(F_ID, '%.3f, %.3f\n', number1, number2);

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by