How to separate log file data containing different strings?

1 Ansicht (letzte 30 Tage)
Hi,
I have my log file data in following format
15303,"Actual RPM","0.0"
15303,"Actual RPM","0.0"
15602,"RPM Error","1434.2168665609909"
15602,"RPM Error","1434.2168665609909"
15602,"Actual RPM","565.7831334390091"
15603,"Actual RPM","565.7831334390091"
15702,"RPM Error","1005.5968324944437"
15702,"RPM Error","1005.5968324944437"
and it continues in the similiar trend. I want to separate Actual RPM and RPM error so that i can plot them individually. How to do that?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 26 Jun. 2016
Bearbeitet: Azzi Abdelmalek am 26 Jun. 2016
fid=fopen('fic.txt')
line=fgetl(fid);
k=1;
while ischar(line)
a{k,1}=line;
line=fgetl(fid)
k=k+1
end
fclose(fid)
rpm_error=regexp(a,'"RPM\s+Error","([\d\.]+)"','tokens','once')
rpm_error=cellfun(@(x) str2double(x),rpm_error,'un',0)
rpm_actual=regexp(a,'"Actual\s+RPM","([\d\.]+)"','tokens','once')
rpm_actual=cellfun(@(x) str2double(x),rpm_actual,'un',0)
  2 Kommentare
FNU Dhanraj
FNU Dhanraj am 26 Jun. 2016
Thanks alot Azzi. I will try this script.
FNU Dhanraj
FNU Dhanraj am 5 Jul. 2016
Hi Azzi,
I am able to separate the data but when i am trying to plot it says not enough input arguments. I am attaching my log fie so that you can take a look.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations 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