Create function for info extraction from .log file

Dear all,
I want to write a function that enables me to extract specific information from a .log file. I am only interested in Event type, code and time. I tried now for 2 hours without any result, I would be very grateful if someone could provide some help...

6 件のコメント

Friedrich
Friedrich 2014 年 5 月 20 日
Have you tried the uiimport function?
Marcel
Marcel 2014 年 5 月 20 日
yes, but then it says the file it not compatible...alternatively when I import it with the import function it is not really automatically done...
Friedrich
Friedrich 2014 年 5 月 20 日
Can you share the file with us?
Marcel
Marcel 2014 年 5 月 20 日
sadly not, it says "file cannot be attached because format is unsupported"
Friedrich
Friedrich 2014 年 5 月 20 日
Change the extension to .m. Then you should be able to upload it.
Marcel
Marcel 2014 年 5 月 20 日
Worked!

サインインしてコメントする。

 採用された回答

Cedric
Cedric 2014 年 5 月 20 日
編集済み: Cedric 2014 年 5 月 20 日

2 投票

You should be able to extract these 3 columns as follows:
content = fileread( 'myFile.txt' ) ;
data = textscan( content, '%*s%*f%s%s%f%*[^\n]', 'HeaderLines', 5 ) ;
where data is a cell array whose 3 cells, data{1} to data{3} (note the curly brackets) contain the relevant columns.
EDITED to match the 5 header lines after seeing your file.

4 件のコメント

Friedrich
Friedrich 2014 年 5 月 20 日
編集済み: Friedrich 2014 年 5 月 20 日
I think the call should be
data= textscan(fid,'%*s%f%s%s%*[^\n]','headerlines',5,'delimiter','\t')
Cedric
Cedric 2014 年 5 月 20 日
The default is {'','\b','\t'}, so no need to specify I guess .. but I'll think about it; it might be more efficient if we specify explicitely the delimiter. Did you perform tests?
Friedrich
Friedrich 2014 年 5 月 21 日
Its not about specifying the delimiter. Its about the formatspec you use. I think your first %*f is wrong.
Cedric
Cedric 2014 年 5 月 23 日
編集済み: Cedric 2014 年 5 月 23 日
No actually, the screenshot doesn't represent well columns. The 0's and 1's belong to the Trial column. The first column that he wants is Event Type, and it is the column with 'Pulse', 'Picture', etc.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

質問済み:

2014 年 5 月 20 日

編集済み:

2014 年 5 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by