Table column formatting to display decimals

Hi, I have constructed a table that reads in data from text file which contains columns of various types i.e. decimals, discrete values and strings.
clc; clear;
options = detectImportOptions('data_train.txt','TextType','char');
options.VariableNames =
{'MPG','Cylinders','Displacement','Horsepower','Weight','Acceleration','Model_Year','Origin','Car_Name'}
options.VariableTypes = {'double','uint8','double','double','int16','double','int16','uint8','char'}
end
When looking at the text file where data is imported from, you can see that values in the MPG column contain fixed decimal place i.e. 18.0, however, my table seems to emit this .0 from numbers who have it as 0 and only keeps non-zero decimal points. This is fairly troubling for me as I want to export the table information in the same format that the file it originate from has.

3 comentarios

Antanas Skiudulas
Antanas Skiudulas el 8 de Nov. de 2018
I have attached a row snippet of my data_train table as it is seen in matlab. I've tried changing the double param in variable types to float, but matlab has no float type.
madhan ravi
madhan ravi el 8 de Nov. de 2018
upload your data file
Antanas Skiudulas
Antanas Skiudulas el 8 de Nov. de 2018
Done.

Iniciar sesión para comentar.

Respuestas (1)

madhan ravi
madhan ravi el 8 de Nov. de 2018

0 votos

double change to float and see what happens?

1 comentario

madhan ravi
madhan ravi el 8 de Nov. de 2018
you can see that values in the MPG column contain fixed decimal place
I don't see any

Iniciar sesión para comentar.

Preguntada:

el 8 de Nov. de 2018

Comentada:

el 8 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by