How to read and retrieve specific data (strings and floats) from this .txt file?
1 view (last 30 days)
Show older comments
Hello!
I saved the matlab command window contents and need to retreive some data from it.
I want to make a .txt or .csv file with three columns - Trial Position RT
This is the general pattern in the text file (converted from the matlab command window):
"The position of this target within its triplet is: first
shuffled =
23
15
17
24
19
21
2
6
12
7
14
10
Trial 1 : The DownArrow key was pressed, post max-fade, at time 4.569 seconds and
at fade value = 1.000"
The desired format for this trial would be :
Trial Position RT
1 first 4.569
I only need the position and RT for the lines that begin with "Trial". Another strange thing may be that the line with the 'Position' always precedes the line with 'Trial'.
The possible positions are - 'first', 'second', 'third'.
The trial line can also state different conditions:
'Trial %d : The %s key was pressed, post max-fade, at time %.3f seconds and at fade value = %.3f\n'
or
'Trial %d : The %s key was pressed, while fading, at time %.3f seconds and at fade value = %.3f\n'
or
'Trial %d : The %s key was pressed before the target\n'.
Thanks very much!
Amit
3 Comments
dpb
on 3 Jan 2019
Edited: dpb
on 3 Jan 2019
For just one-of-a-kind stuff like that it's probably simpler to copy the stuff, paste it into the editor and clean it up manually...
And, if there's a known problem area in the code causing a failure that can't be otherwise avoided by fixing whatever logic error caused it, then enclose that in a try...catch...end block so you can still write what results you did get instead of the rude crash.
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!