problem printing double format values
이전 댓글 표시
I am unable to print the values in double format, suppose if I have a value b=0.394944961213358 [1x1 double] it shows ??? Undefined function or method 'fprinf' for input arguments of type 'char'.
How can I round it to first four decimal values( as 0.3949) and print it to a file.
Thanks Ram
답변 (2개)
Walter Roberson
2011년 11월 29일
The function name is fprintf not fprinf
fprintf(fid, '%.4f', b)
댓글 수: 3
ram m
2011년 11월 29일
Walter Roberson
2011년 11월 29일
In response to the Comment you added to your question:
%before the loop
fid = fopen('YourOutputFile.txt', 'wt');
%inside the loop
fprint(fid, 'i = %d\nb = %.4f\n', i, b);
%after the loop
fclose(fid);
ram m
2011년 11월 30일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!