我只对文件的列感兴趣,(我无法正常加载文件,行的列大小不同)
所以
>load('file.txt'); 无法正常工作,但我想检索该文件中的第一列
回答:
使用textscan加载它,并使用星号跳过其他列。
fid = fopen('file.txt'); textscan(fid, '%*s%*s%s'); % loads only the third column fclose(fid); 假设文件中恰好有三列。如果您还有更多列,则需要:
fid = fopen('file.txt'); twocols = textscan(fid,'%*s%*s%s%*[^\n]'); fclose(fid);
更多&回答...