csvread without decimal point

조회 수: 5 (최근 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