fgetlで空行を認識したい
Show older comments
fgetlで空行を認識したい。
以下のPRGでは、q2.txtをfgetlで読見込みをおこないます。
下記のようにすれば可能ですが、%行でもできると思うのですが、空行を認識しません。
アドバイスをいただけませんか?
%e81.m
fileID = fopen('q2.txt'); % q2' = [1 2 3
while(1)
tline = fgetl(fileID)
if length(tline)==0 fprintf(" blank line\n");
%if tline==[] fprintf(" blank line\n"); % unrecognized, why?
elseif tline<0 fprintf(" file end\n"); break; end
end
fclose(fileID);
%{
%q2.txt
1
2
3
4
5
%}
Accepted Answer
More Answers (0)
Categories
Find more on Beamforming and Direction of Arrival Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!