Filter löschen
Filter löschen

How to read from LOG file

13 Ansichten (letzte 30 Tage)
TAPAN PATEL
TAPAN PATEL am 15 Jun. 2020
Kommentiert: TAPAN PATEL am 5 Jul. 2021
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 Kommentare
Sepehr Ariaei
Sepehr Ariaei am 24 Jun. 2021
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 am 5 Jul. 2021
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Electrophysiology finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by