Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to recognize blank lines in Matlab?

Is there a way to recognize blank lines when you are scanning a text file in Matlab? I want to parse the files based on the blank lines in between the text. Is this possible?

like image 365
Ben Fossen Avatar asked Oct 14 '22 04:10

Ben Fossen


1 Answers

Yes, it's possible. A MATLAB snippet would look something like:

fid = fopen('reader.m');

newline = sprintf('\r\n');
line = fgets(fid);
while ischar(line)
    if strcmp(newline, line)
        disp('Empty line');
    else
        disp('Non-empty line');
    end
    line = fgets(fid);
end
like image 75
Reinderien Avatar answered Oct 25 '22 00:10

Reinderien