【发布时间】:2018-05-30 16:03:24
【问题描述】:
我正在尝试从文本文件中加载数据。前两行是标题,在标题之后的前两列是日期和时间。其余列是浮点数。
数据应该有 11 列,但是,whos 返回大小仅为 1x3
fid = fopen('allunderway.txt', 'rt');
data = textscan(fid, '%{M/dd/yyyy}D %{HH:mm:ss}D %4.2f %2.4f %2.5f %2.4f %2.4f %2.2f %4.2f %3.1f %1.4f', 'HeaderLines', 2, 'CollectOutput', true);
fclose(fid);
whos data
date = data{1};
time = data{2};
wnd_td = data{10};
wnd_ts = data{11};
【问题讨论】:
-
您尝试了
read_table函数吗?否则,您能否将您的数据文件提供为 txt 以便尝试? -
我尝试了
readtable,得到了Warning: Unable to determine the format of the DATETIME data. ...... Warning: Variable names were modified to make them valid MATLAB identifiers. -
我尝试添加 %D ...
T = readtable('allunderway.txt', '%{M/dd/yyyy}D %{HH:mm:ss}D %4.2f %2.4f %2.5f %2.4f %2.4f %2.2f %4.2f %3.1f %1.4f', 'HeaderLines', 2);但readtable的错误表明争论的数量错误
标签: matlab file matrix load data-files