Rounding after using dlmread: how to store exact values?

10 visualizaciones (últimos 30 días)
rkepp12
rkepp12 el 26 de Jun. de 2016
Comentada: Image Analyst el 26 de Jun. de 2016
In some code, I am using the command "dlmread" to get data from ASCII files. To test it, I displayed the matrix of the stored data. When I did this, I found that the data was rounded off to four decimal places in the display? However, most of the data points have more than four decimal places, and I need those numbers.
Does "dlmread" actually round the values? Or is this just a result of displaying the matrix?
  3 comentarios
Stephen23
Stephen23 el 26 de Jun. de 2016
Editada: Stephen23 el 26 de Jun. de 2016
"I found that MATLAB has rounded off..."
MATLAB does not secretly decide to round values that are stored in its memory. Some operation may be causing this "rounding", or perhaps it is an artifact of displaying those values. In either case we would need to see your code, because otherwise we have to rely on using our crystal balls... and sadly they are just not very reliable.
"How can I stop MATLAB from doing this to values?"
We don't know until we can diagnose and identify what is happening. We can't diagnose without seeing the patient. Ergo, edit your question, click the paperclip button to upload both your code and enough data to run the code and see this effect. Also clearly explain how you view the data to observe this effect.
Image Analyst
Image Analyst el 26 de Jun. de 2016
Exactly what does "the file says" mean? Did you write the array back out to disk with dlmwrite() and you're popping it open with wordpad or something???
Please attach your data file and m script file with the paper clip icon.

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 26 de Jun. de 2016
‘Or is this just a result of displaying the matrix?’
Exactly! See the documentation for the format command for the different display options.
  4 comentarios

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 26 de Jun. de 2016
  1 comentario
rkepp12
rkepp12 el 26 de Jun. de 2016
I tried using "format long" and it is still rounding off numbers when I don't want it to...

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by