2010-06-16 13 views

cevap

2

Evet, mümkün. Bir MATLAB pasajının nasıl görünecektir:

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 
+3

çalışıyor .. –

2

İşte bir olasılık: şimdi \ r ... olmadan

fid = fopen('myfile.txt'); 
lines = textscan(fid, '%s', 'Delimiter', '\n'); 
fclose(fid); 
lines = lines{1}; 
% lines now contains a cell array of strings, 
% one per line in the file. 

% Find all the blank lines using cellfun: 
blank_lines = find(cellfun('isempty', lines)); 
+0

Ayrıca yorumlarla çalışır: 'lines = textscan (fid, '% s', 'CommentStyle', '#')' – Wok

0

O "Matlab" dedi düşünüyorum

fid = fopen('reader.m'); 

newline = sprintf('\n'); 
line = fgets(fid); 
while ischar(line) 
    if strcmp(newline, line) 
     disp('Empty line'); 
    else 
     disp('Non-empty line'); 
    end 
    line = fgets(fid); 
end 
İlgili konular