필터 지우기
필터 지우기

How to read from LOG file

조회 수: 13 (최근 30일)
TAPAN PATEL
TAPAN PATEL 2020년 6월 15일
댓글: TAPAN PATEL 2021년 7월 5일
Hello all,
After trying a lot with 'fopen' and 'textscan' here I am posting my issue.
I have text file as attached. My goal is to read numerical values of 'HLP' and 'PSC' in saperate arrays and also the 1016 complex values which comes after 'Accum Len 1016' in another array.
since text file is updating in real time in windows 10, the above three arrays also needs to be read again and again.
After each reading I need to perform some calculations and plot the data.
After ploting and before reading new values I also need to store the previus data each time(But this is otional as of now).
here is my code:
f1 = fullfile(' file name ');
fid1 = fopen(f1);
while ~feof(fid1)
tline1 = fgetl(fid1);
if contains (tline1,'HLP')
HLP1 = textscan(tline1,'%s',7,'Delimiter','(,)');
% HLP1 = textscan(tline1,'HLP=%n',7,'Delimiter','(,)');
% Here some calculations
else if contains (tline1,'Accum Len')
Acc1 = double(cell2mat(textscan(fid1,'%d16 %d16',1016,'Delimiter',',')));
Abs_Acc1=abs(Acc1);
Mag1 = max(Abs_Acc1,[],2) + 1/4*min(Abs_Acc1,[],2);
% Here some calculations
else if contains (tline1,'PSC')
PSC1 = double(cell2mat(textscan(tline1,'PSC=%u16',7,'Delimiter','(,)')));
% Here some calculations
end
end
end
end
fclose(fid1);
  댓글 수: 2
Sepehr Ariaei
Sepehr Ariaei 2021년 6월 24일
Hello @TAPAN PATEL.
I have the same exact issue. I have a log file which is updating. I could not resolve it. Do you have anything now that could help me?
Thanks in advance
Sepehr
TAPAN PATEL
TAPAN PATEL 2021년 7월 5일
Hallo Sepehr,
I am sorry, I could't find any solution to fetch data from upadating file.
What I learn is that in MS Windows it may be difficult because of some mandatory locking on file.
Regards,
Tapan

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Electrophysiology에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by