problem printing double format values
Mostrar comentarios más antiguos
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
1 comentario
ram m
el 29 de Nov. de 2011
Respuestas (2)
Walter Roberson
el 29 de Nov. de 2011
The function name is fprintf not fprinf
fprintf(fid, '%.4f', b)
3 comentarios
ram m
el 29 de Nov. de 2011
Walter Roberson
el 29 de Nov. de 2011
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
el 30 de Nov. de 2011
Honglei Chen
el 29 de Nov. de 2011
0 votos
You missed a t, it's fprintf, not fprinf
1 comentario
ram m
el 29 de Nov. de 2011
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!