Matlab : Storing large numbers

2019-09-02 00:31发布

My csv file looks like this

'have', 1436271616097.0, 33.0, 'noChange', 1436271538982.0
'four', 1436271616130.0, 466.0, 'noChange', 1436271538982.0
'have', 1436271616596.0, 467.0, 'noChange', 1436271538982.0
'four', 1436271617063.0, 100.0, 'noChange', 1436271538982.0

I tried using [num, txt, raw] = csvread('test.csv') it shows error saying Too many output arguments.

i tried converting my csv file to .xlsx but then it changes the numbers to this,

have    1.44E+12    33   noChange   1.44E+12
four    1.44E+12    466  noChange   1.44E+12
have    1.44E+12    467  noChange   1.44E+12
four    1.44E+12    100  noChange   1.44E+12
minutes 1.44E+12    666  noChange   1.44E+12

then i used [num, txt, raw] = xlsread('test.xls') but the problem is that if i display eyeT = vpa(eyeT(:,1)) it shows same float value. how can i use textscan for this?

1条回答
唯我独甜
2楼-- · 2019-09-02 01:21

This as a short example using textscan for the mentioned csv-file. This gives you a cell array for each column.

% reading the data
file = fopen('file.csv');
F = textscan(file,'%s %f %f %s %f','Delimiter',',');

format long    % to show all the digits of the large number
celldisp(F)    % display the values of all cells

This is the result:

F{1}{1} =
'have'
F{1}{2} =
'four'
F{1}{3} =
'have'
F{1}{4} =
'four'
F{2} =
   1.0e+12 *
   1.436271616097000
   1.436271616130000
   1.436271616596000
   1.436271617063000
F{3} =
    33
   466
   467
   100
F{4}{1} =
'noChange'
F{4}{2} =
'noChange'
F{4}{3} =
'noChange'
F{4}{4} =
'noChange'
F{5} =
   1.0e+12 *
   1.436271538982000
   1.436271538982000
   1.436271538982000
   1.436271538982000
查看更多
登录 后发表回答