csvread without decimal point

2 次查看(过去 30 天)
Sepp
Sepp 2014-10-19
回答: Sepp 2014-10-20
Hi
I have a text file which has data of the following format:
17,1413736800061,4,2
17,1413736800153,12,0
17,1413736800239,6,2
17,1413736800324,5,1
17,1413736800410,6,1
17,1413736800496,6,1
.....
.....
Now, when I read in the file with M = csvread(fileName); and then I print the matrix M in Matlab I get values like the following (the values do not correspond to the ones above).
0.000000000017000 1.413737868957000 0.000000000003000 0
0.000000000017000 1.413737869045000 0.000000000008000 0.000000000002000
0.000000000017000 1.413737869128000 0.000000000003000 0
0.000000000017000 1.413737869211000 0.000000000003000 0.000000000002000
0.000000000017000 1.413737869294000 0.000000000003000 0
0.000000000017000 1.413737869376000 0.000000000002000 0.000000000002000
0.000000000017000 1.413737869460000 0.000000000003000 0
0.000000000017000 1.413737869550000 0.000000000010000 0.000000000002000
0.000000000017000 1.413737869634000 0.000000000004000 0
How can I get just normal vlues without a decimal point?

采纳的回答

dpb
dpb 2014-10-19
But it is the input data...you're ignoring the scale factor Matlab uses when display disparate values on the command window...
>> type sepp.csv
17,1413736800061,4,2
17,1413736800153,12,0
17,1413736800239,6,2
17,1413736800324,5,1
17,1413736800410,6,1
17,1413736800496,6,1
>> csvread('sepp.csv')
ans =
1.0e+12 *
0.0000 1.4137 0.0000 0.0000
0.0000 1.4137 0.0000 0
0.0000 1.4137 0.0000 0.0000
0.0000 1.4137 0.0000 0.0000
0.0000 1.4137 0.0000 0.0000
0.0000 1.4137 0.0000 0.0000
>> [ans(:,1) ans(:,3)]
ans =
17 4
17 12
17 6
17 5
17 6
17 6
>>
NB: the 1.0e+12 * in the beginning of the array after reading the file; it's significant.
To see the values are really there, then displayed the first and third columns so the scaling is unity.

更多回答(1 个)

Sepp
Sepp 2014-10-20
Thank you very much. It's my fault, I didn't see the scaling factor because I have such an enormous amount of data.

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by