Importing XLS to a dataset truncates decimal places

3 visualizaciones (últimos 30 días)
Jason
Jason el 30 de Jun. de 2014
Comentada: Star Strider el 2 de Jul. de 2014
Hi all, I am importing a small XLS file into a dataset with mixed numerical and string data. Upon import Matlab truncates all decimals to 4 places. I don't have any super long # of decimals, but the file contains currency rates which extend up to 8 decimal places.
Is there any way to retain the number of decimal places in the dataset from the original XLS file using mixed data types?
Thanks.

Respuestas (1)

Star Strider
Star Strider el 30 de Jun. de 2014
MATLAB is most likely displaying only 4 decimal places. All the data should be there. Consider temporarily setting:
format long
or other such options. See the documentation for format for details.
  3 comentarios
Jason
Jason el 1 de Jul. de 2014
Hi all, thanks for your comments. However, this is not a viewing issue. Matlab is truncating the decimals places to 4. The reason I know is because after importing the file I remove a few columns and export the data back out to XLS and the decimals are truncated to 4 places.
I was using the command:
XLSData = dataset('XLSFile', TempFilePath, 'ReadVarNames', false);
It appears the "'ReadVarNames', false" command causes the decimal truncation when there are column headers in the original XLS file. After removing the "'ReadVarNames', false" command the decimals are no longer truncated. I had to adjust my code somewhat as the column headers are now the column variable names, but that is trivial.
Thanks
Star Strider
Star Strider el 2 de Jul. de 2014
Our pleasure!

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by