While reading data from text file line by line using fget1, If error on data how to go to next line?
古いコメントを表示
Hi, I am new to this form so sorry for any mistakes.
My question is what I am after. So I have set of data been read line by line using fget1, but my data can have sometimes lines or some data missing.
So what I need program to do is if there is empty line but not EOf, or if data missing within each line just fill with NaN or skip and go to next line.
example of my code:
try
tline = fgetl(fileID);
while (tline ~= -1)
if (strncmp(tline,'01',2))
%get data
Time_num=addtodate(Time_num,100,'millisecond');
Data = textscan(tline,'%*s%*s%*s%d16%d16%d16%d16%d16%d16%c%c%c%c%c%c\n'...
,'delimiter',',');
DATA(dataLine,:) = cell2mat(Data(1,1:6));
%V_A(dataLine,:)=Data(1,7:12);
Time_Axis(dataLine,:)=Time_num;
dataLine=dataLine+1;
end
end
catch err
errordlg('There has been an error with your Import File.',' File Error #2017');
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!