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?
댓글 수: 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에서 Low-Level File I/O에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!