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?
13 次查看(过去 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?
0 个评论
采纳的回答
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 个)
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 Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!