Import data from text file

2 次查看(过去 30 天)
Rica
Rica 2017-9-11
编辑: KL 2017-9-11
Hi, i want to import data from a text file. the text is consisted of 201 column. The first column is a time column:
%
Hour:minute.second.millisecond
00:00.34.294
00:00.35.090
00:00.35.839
00:00.36.619
the oder 200 column are floting number. is textscan the approprite function to do this? Schould i specifiy the Format of all the 201 clumns, or is there any tricky function?
Thank you!

采纳的回答

Guillaume
Guillaume 2017-9-11
use readtable which should be able to figure out the format of your file on its own. It will probably fail for your time column and import it as text instead. This can be fixed either beforehand by overriding the import options or afterward with:
yourtable.yourfirstcolumn = datetime(yourtable.yourfirstcolumn, 'InputFormat', 'HH:mm.ss.S', 'Format', 'HH:mm.ss.SSS');
  1 个评论
KL
KL 2017-9-11
编辑:KL 2017-9-11
I agree! readtable(filename) should be enough if that file is properly formatted.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by