txt文件内容:20180324 13093 X431ZKGD1308 01 01 4312 24.1055 24.1256 24.1185 24.1103 24.1266 24.1291 24.1164 24.1194 24.1204 24.1195 24.1169 NULL 24.1094
读取完之后,NULL那个位置是一个空值
比如:A=[20180324 13093 X431ZKGD1308 01 01 4312 24.1055 24.1256 24.1185 24.1103 24.1266 24.1291 24.1164 24.1194 24.1204 24.1195 24.1169 24.1094]
或者是:A=[20180324 13093 X431ZKGD1308 01 01 4312 24.1055 24.1256 24.1185 24.1103 24.1266 24.1291 24.1164 24.1194 24.1204 24.1195 24.1169 NAN 24.1094]
matlab中如何读取含有null的txt文件
答案:1 悬赏:10
解决时间 2021-12-14 04:54
- 提问者网友:梧桐不渝
- 2021-12-14 01:05
最佳答案
- 二级知识专家网友:无字情书
- 2021-12-14 02:14
先打开文copy件
[filename,filepath]=uigetfile('*.txt','Select Input file');
file = [filepath filename];
fid = fopen(file,'rt');
if fid == -1
('Error opening the file')
end
%%读取文件
while 1
nextline = fgetl(fid); %读第一行
if ~isstr(nextline), break, end %读到最后跳出
disp(nextline);%这行可以不要zhidao
a = sscanf(nextline, ' %f %f ');%读取数据,根据你自己的需要改
end
end
[filename,filepath]=uigetfile('*.txt','Select Input file');
file = [filepath filename];
fid = fopen(file,'rt');
if fid == -1
('Error opening the file')
end
%%读取文件
while 1
nextline = fgetl(fid); %读第一行
if ~isstr(nextline), break, end %读到最后跳出
disp(nextline);%这行可以不要zhidao
a = sscanf(nextline, ' %f %f ');%读取数据,根据你自己的需要改
end
end
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯