フィルターのクリア

How to read from LOG file

11 ビュー (過去 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 Center および File ExchangeElectrophysiology についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by