1
我正在使用textscan
导入数据。我可以成功导入格式正确的数据。我无法正确处理格式不正确的数据。以下是数据的格式。在Matlab中使用textscan处理数据格式不正确的数据
JeB2021Da 12-13 and stuff, 1, 1, 0, 1, 0, 1, 1, 1, 3, 1, 99, 0, 0, 0,
JoB2021Ha 12-13 and stuff, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 99, 2, 1, 0,
JoP2021Co 12-13 and stuff, not enough samples
MaA2021Be 12-13 and stuff, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 99, 1, 0, 0,
MaA2021Ma 12-13 and stuff, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 99, 1, 0, 0,
我该如何处理数据,即not enough samples
?因为目前数据结构不一致。正在生产的数据结构是17 x 1
和16 x 14
。我想导入字符串,因为它在数据中。所以not enough samples
将被导入。以下是我正在使用的代码。
fid = fopen('./file.txt','r');
fmt = ['%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d'];
d = textscan(fid, fmt, 'CollectOutput', 1,'Delimiter',',','headerLines', 1, 'EmptyValue', 0);
我试图与EmptyValue
标志来处理它,但它不工作。任何帮助是极大的赞赏。