Extracting data from an unformatted text file

1 view (last 30 days)
Yro
Yro on 29 Apr 2021
Commented: Rik on 30 Apr 2021
Hi, I want to extract certain values from an unformatted text file, in the example I use the regexp function entering the format of the data I want to extract.
(file format)
...
<<<<< Function evaluation summary (I1): 582 total (581 new, 1 duplicate)
<<<<< Best parameters =
31 x1
7 x2
87 x3
83 x4
3 x5
63 x6
5 x7
72 x8
12 x9
51 x10
67 x11
82 x12
81 x13
35 x14
52 x15
13 x16
32 x17
19 x18
73 x19
24 x20
50 x21
71 x22
61 x23
22 x24
23 x25
27 x26
58 x27
77 x28
1 x29
<<<<< Best objective function =
1.0119441809e+00
...
The output does not work because it extracts undesired values.
str = fileread('OUTPUT.out');
expression = '\d*\s\w\w' ;
regexp = regexp(str,expression, 'match');
How can I extract the values with the presented format?
  2 Comments
Mathieu NOE
Mathieu NOE on 30 Apr 2021
hello
what do you want to extract and in which format ?
Rik
Rik on 30 Apr 2021
You should rename your file to txt and attach it. That way, we can taylor our code to your exact file format.

Sign in to comment.

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!