csvread without decimal point

5 visualizzazioni (ultimi 30 giorni)
Sepp
Sepp il 19 Ott 2014
Risposto: Sepp il 20 Ott 2014
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?

Risposta accettata

dpb
dpb il 19 Ott 2014
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.

Più risposte (1)

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

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by