How to read the 3rd column in a line and skip if value is greater than E+37
4 次查看(过去 30 天)
显示 更早的评论
Hello all,
I have a text file with below given format.
16.Mrz.14 10:12:34
16.Mrz.14 10:12:37 -01,22522E-09
16.Mrz.14 10:12:40 -00,90903E-09
16.Mrz.14 10:12:42 -00,72633E-09
16.Mrz.14 10:12:45 -00,59084E-09
16.Mrz.14 10:12:48 -00,50685E-09
16.Mrz.14 10:12:50 -00,42215E-09
16.Mrz.14 10:12:53 -00,38118E-09
16.Mrz.14 10:12:55 -00,32913E-09
16.Mrz.14 10:12:58 -00,29374E-09
16.Mrz.14 10:13:00 -00,25394E-09
16.Mrz.14 10:13:03 +9,900000E+37OADC,+1629586.578736secs,+12454976RDNG#
16.Mrz.14 10:13:06 -000,0389E-09
16.Mrz.14 10:13:09 -000,2374E-09
16.Mrz.14 10:13:13 -000,1355E-09
I have a code written to skip incomplete lines using number of columns but the same logic didn't work when i tried skipping the row with E+37. Could someone tell me how to skip all the rows with the format 16.Mrz.14 10:13:03 +9,900000E+37OADC,+1629586.578736secs,+12454976RDNG? Looking forward to your help
2 个评论
回答(1 个)
Azzi Abdelmalek
2014-4-5
fid = fopen('file.txt');
res={};
while ~feof(fid)
res{end+1,1} =fgetl(fid);
end
fclose(fid);
res(~cellfun('isempty',regexp(res,'E\+37','match')))=[]
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!