Extracting data from an unformatted text file
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Rik
el 30 de Abr. de 2021
You should rename your file to txt and attach it. That way, we can taylor our code to your exact file format.
Respuestas (0)
Ver también
Categorías
Más información sobre Text Data Preparation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!